"Fossies" - the Fresh Open Source Software Archive

Member "Atom/resources/app/apm/node_modules/mv/node_modules/ncp/bin/ncp" (11 Apr 2017, 1084 Bytes) of package /windows/misc/atom-windows.zip:


As a special service "Fossies" has tried to format the requested text file into HTML format (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 #!/usr/bin/env node
    2 
    3 
    4 
    5 
    6 var ncp = require('../lib/ncp'),
    7     args = process.argv.slice(2),
    8     source, dest;
    9 
   10 if (args.length < 2) {
   11   console.error('Usage: ncp [source] [destination] [--filter=filter] [--limit=concurrency limit]');
   12   process.exit(1);
   13 }
   14 
   15 // parse arguments the hard way
   16 function startsWith(str, prefix) {
   17   return str.substr(0, prefix.length) == prefix;
   18 }
   19 
   20 var options = {};
   21 args.forEach(function (arg) {
   22   if (startsWith(arg, "--limit=")) {
   23     options.limit = parseInt(arg.split('=', 2)[1], 10);
   24   }
   25   if (startsWith(arg, "--filter=")) {
   26     options.filter = new RegExp(arg.split('=', 2)[1]);
   27   }
   28   if (startsWith(arg, "--stoponerr")) {
   29     options.stopOnErr = true;
   30   }
   31 });
   32 
   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);
   38     });
   39     process.exit(1);
   40   }
   41   else if (err) {
   42     console.error('An error has occurred.');
   43     console.error(err.stack || err.message);
   44     process.exit(1);
   45   }
   46 });
   47 
   48