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.

ncp 1.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #!/usr/bin/env node
  2. var ncp = require('../lib/ncp'),
  3. args = process.argv.slice(2),
  4. source, dest;
  5. if (args.length < 2) {
  6. console.error('Usage: ncp [source] [destination] [--filter=filter] [--limit=concurrency limit]');
  7. process.exit(1);
  8. }
  9. // parse arguments the hard way
  10. function startsWith(str, prefix) {
  11. return str.substr(0, prefix.length) == prefix;
  12. }
  13. var options = {};
  14. args.forEach(function (arg) {
  15. if (startsWith(arg, "--limit=")) {
  16. options.limit = parseInt(arg.split('=', 2)[1], 10);
  17. }
  18. if (startsWith(arg, "--filter=")) {
  19. options.filter = new RegExp(arg.split('=', 2)[1]);
  20. }
  21. if (startsWith(arg, "--stoponerr")) {
  22. options.stopOnErr = true;
  23. }
  24. });
  25. ncp.ncp(args[0], args[1], options, function (err) {
  26. if (Array.isArray(err)) {
  27. console.error('There were errors during the copy.');
  28. err.forEach(function (err) {
  29. console.error(err.stack || err.message);
  30. });
  31. process.exit(1);
  32. }
  33. else if (err) {
  34. console.error('An error has occurred.');
  35. console.error(err.stack || err.message);
  36. process.exit(1);
  37. }
  38. });