6 var ncp = require('../lib/ncp'),
7 args = process.argv.slice(2),
10 if (args.length < 2) {
11 console.error('Usage: ncp [source] [destination] [--filter=filter] [--limit=concurrency limit]');
15 // parse arguments the hard way
16 function startsWith(str, prefix) {
17 return str.substr(0, prefix.length) == prefix;
21 args.forEach(function (arg) {
22 if (startsWith(arg, "--limit=")) {
23 options.limit = parseInt(arg.split('=', 2)[1], 10);
25 if (startsWith(arg, "--filter=")) {
26 options.filter = new RegExp(arg.split('=', 2)[1]);
28 if (startsWith(arg, "--stoponerr")) {
29 options.stopOnErr = true;
33 ncp.ncp(args[0], args[1], options, function (err) {
34 if (Array.isArray(err)) {
35 console.error('There were errors during the copy.');
36 err.forEach(function (err) {
37 console.error(err.stack || err.message);
42 console.error('An error has occurred.');
43 console.error(err.stack || err.message);