Cross-platform recursive file copying library that replicates Unix 'cp -R' command functionality
66
Build a utility that recursively copies files from a source directory to a destination directory while allowing callers to filter which paths are copied by pattern or by predicate. When no filters are provided, everything under the source should be copied. The utility should finish with a deterministic list of what was copied.
includePattern, only files whose absolute paths match that pattern are copied; non-matching files and directories are left untouched at the destination. @testfilterPredicate, it receives each absolute path that would be copied; any path for which the predicate returns false must not be copied. The predicate should be applied to both files and directories. @testincludePattern and filterPredicate are provided, a path is copied only if it matches the pattern and the predicate returns true. The final list of copied paths should reflect this combined filtering. @test@generates
/**
* Recursively copies selected paths from source to destination.
*
* @param {Object} options
* @param {string} options.source - Source directory path.
* @param {string} options.destination - Destination directory path.
* @param {RegExp|string} [options.includePattern] - Only copy paths whose absolute path matches this pattern.
* @param {(path: string) => boolean} [options.filterPredicate] - Return true to keep the path; false to skip it.
* @param {boolean} [options.cleanDestination] - When true, clear the destination before copying.
* @returns {Promise<string[]>} Resolves with a sorted list of absolute destination paths that were copied.
*/
export async function selectiveCopy(options);Provides recursive file copying with optional filtering support.
Install with Tessl CLI
npx tessl i tessl/npm-cprdocs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10