Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

executable file 46 lines (38 sloc) 1.084 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
#!/usr/bin/env node




var ncp = require('../lib/ncp'),
    args = process.argv.slice(2),
    source, dest;

if (args.length < 2) {
  console.error('Usage: ncp [source] [destination] [--filter=filter] [--limit=concurrency limit]');
  process.exit(1);
}

// parse arguments the hard way
function startsWith(str, prefix) {
  return str.substr(0, prefix.length) == prefix;
}

var options = {};
args.forEach(function (arg) {
  if (startsWith(arg, "--limit=")) {
    options.limit = parseInt(arg.split('=', 2)[1], 10);
  }
  if (startsWith(arg, "--filter=")) {
    options.filter = new RegExp(arg.split('=', 2)[1]);
  }
  if (startsWith(arg, "--stoponerr")) {
    options.stopOnErr = true;
  }
});

ncp.ncp(args[0], args[1], options, function (err) {
  if (Array.isArray(err)) {
    console.error('There were errors during the copy.');
    err.forEach(function (err) {
      console.error(err.stack || err.message);
    });
    process.exit(1);
  }
  else if (err) {
    console.error('An error has occurred.');
    console.error(err.stack || err.message);
    process.exit(1);
  }
});
Something went wrong with that request. Please try again.