Ohm-Management - Projektarbeit B-ME
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

README.md 2.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. # ncp - Asynchronous recursive file & directory copying
  2. [![Build Status](https://secure.travis-ci.org/AvianFlu/ncp.png)](http://travis-ci.org/AvianFlu/ncp)
  3. Think `cp -r`, but pure node, and asynchronous. `ncp` can be used both as a CLI tool and programmatically.
  4. ## Command Line usage
  5. Usage is simple: `ncp [source] [dest] [--limit=concurrency limit]
  6. [--filter=filter] --stopOnErr`
  7. The 'filter' is a Regular Expression - matched files will be copied.
  8. The 'concurrency limit' is an integer that represents how many pending file system requests `ncp` has at a time.
  9. 'stoponerr' is a boolean flag that will tell `ncp` to stop immediately if any
  10. errors arise, rather than attempting to continue while logging errors. The default behavior is to complete as many copies as possible, logging errors along the way.
  11. 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.
  12. ## Programmatic usage
  13. Programmatic usage of `ncp` is just as simple. The only argument to the completion callback is a possible error.
  14. ```javascript
  15. var ncp = require('ncp').ncp;
  16. ncp.limit = 16;
  17. ncp(source, destination, function (err) {
  18. if (err) {
  19. return console.error(err);
  20. }
  21. console.log('done!');
  22. });
  23. ```
  24. You can also call ncp like `ncp(source, destination, options, callback)`.
  25. `options` should be a dictionary. Currently, such options are available:
  26. * `options.filter` - a `RegExp` instance, against which each file name is
  27. tested to determine whether to copy it or not, or a function taking single
  28. parameter: copied file name, returning `true` or `false`, determining
  29. whether to copy file or not.
  30. * `options.transform` - a function: `function (read, write) { read.pipe(write) }`
  31. used to apply streaming transforms while copying.
  32. * `options.clobber` - boolean=true. if set to false, `ncp` will not overwrite
  33. destination files that already exist.
  34. * `options.dereference` - boolean=false. If set to true, `ncp` will follow symbolic
  35. links. For example, a symlink in the source tree pointing to a regular file
  36. will become a regular file in the destination tree. Broken symlinks will result in
  37. errors.
  38. * `options.stopOnErr` - boolean=false. If set to true, `ncp` will behave like `cp -r`,
  39. and stop on the first error it encounters. By default, `ncp` continues copying, logging all
  40. errors and returning an array.
  41. * `options.errs` - stream. If `options.stopOnErr` is `false`, a stream can be provided, and errors will be written to this stream.
  42. Please open an issue if any bugs arise. As always, I accept (working) pull requests, and refunds are available at `/dev/null`.