Skip to content

iexitdev/copy-tree-modern

copy-tree-modern

Modern recursive copy utilities for JavaScript and TypeScript.

copy-tree-modern is a migration path for callback-era packages such as ncp. It uses Node's native recursive copy implementation, keeps the useful callback shape for old code, and exposes a promise-first API for new code.

Install

npm install copy-tree-modern

Usage

Promise API

import { copyTree } from "copy-tree-modern";

await copyTree("fixtures/site", "dist/site", {
  overwrite: true,
  filter: (source) => !source.endsWith(".map")
});

Callback migration API

import { ncp } from "copy-tree-modern";

ncp("fixtures/site", "dist/site", { clobber: false }, (error) => {
  if (error) throw error;
});

API

copyTree(source, destination, options?)

Copies a file or directory tree. Parent directories for destination are created automatically.

Options:

  • overwrite: replace existing files. Defaults to true.
  • errorOnExist: throw if the destination exists and overwrite is disabled.
  • dereference: follow symlinks.
  • preserveTimestamps: preserve copied file timestamps.
  • verbatimSymlinks: preserve symlink text exactly where the platform supports it.
  • filter: sync or async predicate called with (source, destination).

ncp(source, destination, options?, callback)

Callback-compatible adapter for code migrating away from ncp.

Notes

This package targets Node 18 and newer. It intentionally does not reimplement stream transforms or old concurrency internals because Node's native fs.cp handles the copy traversal directly.

Migration Position

copy-tree-modern is an independent alternative or migration helper for projects moving away from ncp. It is not affiliated with the original package maintainers or project.

For release context, see the local migration guide, examples, compatibility notes, source metadata, and adoption plan.

About

Modern recursive copy utility with promise and ncp-compatible callback APIs.

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors