CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-cpr

Cross-platform recursive file copying library that replicates Unix 'cp -R' command functionality

66

1.00x
Overview
Eval results
Files

task.mdevals/scenario-5/

Filtered Copy Sync

Create a small utility that synchronizes a subset of files from one directory to another using a caller-provided filter, surfacing a clear failure when nothing qualifies for copying.

Capabilities

Filtered copy respects selection

  • When copying from a directory that contains both matching and non-matching files, only paths that satisfy the provided filter end up in the destination, preserving their relative structure and returning the absolute destination paths in sorted order. @test

Errors when nothing matches

  • If the filter excludes every path from the source, the operation rejects with an error whose message includes "No files to copy" and leaves the destination empty or unchanged. @test

Optional clean sync

  • When clean is true and the destination already contains files, the existing destination tree is removed before copying so the final contents mirror the filtered source. @test

Implementation

@generates

API

export type PathFilter = RegExp | ((absolutePath: string) => boolean);

export interface FilterCopyOptions {
  filter: PathFilter;
  clean?: boolean;
}

export function copyFilteredTree(
  source: string,
  destination: string,
  options: FilterCopyOptions
): Promise<string[]>;

Dependencies { .dependencies }

cpr { .dependency }

Recursively copies files and directories with filtering, destination cleanup, and error propagation for empty copy sets. @satisfied-by

Install with Tessl CLI

npx tessl i tessl/npm-cpr

tile.json