UNPKG

1.52 kBMarkdownView Raw
1# ncp - Asynchronous recursive file & directory copying
2
3Think `cp -r`, but pure node, and asynchronous. `ncp` can be used both as a CLI tool and programmatically.
4
5## Command Line usage
6
7Usage is simple: `ncp [source] [dest] [--limit=concurrency limit] [--filter=filter]`
8
9The 'filter' is a Regular Expression - matched files will be copied.
10
11The 'concurrency limit' is an integer that represents how many pending file system requests `ncp` has at a time.
12
13If 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.
14
15## Programmatic usage
16
17Programmatic usage of `ncp` is just as simple. The only argument to the completion callback is a possible error.
18
19```javascript
20var ncp = require('ncp').ncp;
21
22ncp.limit = 16;
23
24ncp(source, destination, function (err) {
25 if (err) {
26 return console.error(err);
27 }
28 console.log('done!');
29});
30```
31
32You can also call ncp like `ncp(source, destination, options, callback)`.
33`options` should be a dictionary. Currently, such options are available:
34
35 * `options.filter` - a `RegExp` instance, against which each file name is
36 tested to determine whether to copy it or not, or a function taking single
37 parameter: copied file name, returning `true` or `false`, determining
38 whether to copy file or not.
39
40Please open an issue if any bugs arise. As always, I accept (working) pull requests, and refunds are available at `/dev/null`.