1 # ncp - Asynchronous recursive file & directory copying
3 [![Build Status](https://secure.travis-ci.org/AvianFlu/ncp.png)](http://travis-ci.org/AvianFlu/ncp)
5 Think `cp -r`, but pure node, and asynchronous. `ncp` can be used both as a CLI tool and programmatically.
9 Usage is simple: `ncp [source] [dest] [--limit=concurrency limit]
10 [--filter=filter] --stopOnErr`
12 The 'filter' is a Regular Expression - matched files will be copied.
14 The 'concurrency limit' is an integer that represents how many pending file system requests `ncp` has at a time.
16 'stopOnErr' is a boolean flag that will tell `ncp` to stop immediately if any
17 errors arise, rather than attempting to continue while logging errors.
19 If there are no errors, `ncp` will output `done.` when complete. If there are errors, the error messages will be logged to `stdout` and to `./ncp-debug.log`, and the copy operation will attempt to continue.
23 Programmatic usage of `ncp` is just as simple. The only argument to the completion callback is a possible error.
26 var ncp = require('ncp').ncp;
30 ncp(source, destination, function (err) {
32 return console.error(err);
38 You can also call ncp like `ncp(source, destination, options, callback)`.
39 `options` should be a dictionary. Currently, such options are available:
41 * `options.filter` - a `RegExp` instance, against which each file name is
42 tested to determine whether to copy it or not, or a function taking single
43 parameter: copied file name, returning `true` or `false`, determining
44 whether to copy file or not.
46 * `options.transform` - a function: `function (read, write) { read.pipe(write) }`
47 used to apply streaming transforms while copying.
49 * `options.clobber` - boolean=true. if set to false, `ncp` will not overwrite
50 destination files that already exist.
52 Please open an issue if any bugs arise. As always, I accept (working) pull requests, and refunds are available at `/dev/null`.