1 | # ncp - Asynchronous recursive file & directory copying
|
2 |
|
3 | Think `cp -r`, but pure node, and asynchronous. `ncp` can be used both as a CLI tool and programmatically.
|
4 |
|
5 | ## Command Line usage
|
6 |
|
7 | Usage is simple: `ncp [source] [dest] [--limit=concurrency limit] [--filter=filter]`
|
8 |
|
9 | The 'filter' is a Regular Expression - matched files will be copied.
|
10 |
|
11 | The 'concurrency limit' is an integer that represents how many pending file system requests `ncp` has at a time.
|
12 |
|
13 | 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.
|
14 |
|
15 | ## Programmatic usage
|
16 |
|
17 | Programmatic usage of `ncp` is just as simple. The only argument to the completion callback is a possible error.
|
18 |
|
19 | ```javascript
|
20 | var ncp = require('ncp').ncp;
|
21 |
|
22 | ncp.limit = 16;
|
23 |
|
24 | ncp(source, destination, function (err) {
|
25 | if (err) {
|
26 | return console.error(err);
|
27 | }
|
28 | console.log('done!');
|
29 | });
|
30 | ```
|
31 |
|
32 | You 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 |
|
40 | Please open an issue if any bugs arise. As always, I accept (working) pull requests, and refunds are available at `/dev/null`.
|