diff --git a/README.md b/README.md index 9480032..8f9f424 100644 --- a/README.md +++ b/README.md @@ -27,11 +27,15 @@ var ncp = require('ncp').ncp; ncp.limit = 16; -ncp(source, destination, function (err) { +ncp(source, destination, (err) => { + //if the process have errors if (err) { return console.error(err); } + //no error | process successfully completed + else{ console.log('done!'); + } }); ``` diff --git a/lib/ncp.js b/lib/ncp.js index 96eed47..7f019bd 100644 --- a/lib/ncp.js +++ b/lib/ncp.js @@ -1,5 +1,5 @@ var fs = require('fs'), - path = require('path'); +var path = require('path'); module.exports = ncp; ncp.ncp = ncp; @@ -31,7 +31,7 @@ function ncp (source, dest, options, callback) { startCopy(currentPath); - function startCopy(source) { + startCopy = (source) => { started++; if (filter) { if (filter instanceof RegExp) { @@ -48,7 +48,7 @@ function ncp (source, dest, options, callback) { return getStats(source); } - function getStats(source) { + getStats = (source) => { var stat = dereference ? fs.stat : fs.lstat; if (running >= limit) { return setImmediate(function () { @@ -81,7 +81,7 @@ function ncp (source, dest, options, callback) { }); } - function onFile(file) { + onFile = (file) => { var target = file.name.replace(currentPath, targetPath); if(rename) { target = rename(target); @@ -110,7 +110,7 @@ function ncp (source, dest, options, callback) { }); } - function copyFile(file, target) { + copyFile = (file, target)=> { var readStream = fs.createReadStream(file.name), writeStream = fs.createWriteStream(target, { mode: file.mode }); @@ -134,7 +134,7 @@ function ncp (source, dest, options, callback) { }); } - function rmFile(file, done) { + rmFile = (file, done) => { fs.unlink(file, function (err) { if (err) { return onError(err); @@ -143,7 +143,7 @@ function ncp (source, dest, options, callback) { }); } - function onDir(dir) { + onDir = (dir) => { var target = dir.name.replace(currentPath, targetPath); isWritable(target, function (writable) { if (writable) { @@ -153,7 +153,7 @@ function ncp (source, dest, options, callback) { }); } - function mkDir(dir, target) { + mkDir = (dir, target) => { fs.mkdir(target, dir.mode, function (err) { if (err) { return onError(err); @@ -162,7 +162,7 @@ function ncp (source, dest, options, callback) { }); } - function copyDir(dir) { + copyDir = (dir) => { fs.readdir(dir, function (err, items) { if (err) { return onError(err); @@ -174,7 +174,7 @@ function ncp (source, dest, options, callback) { }); } - function onLink(link) { + onLink = (link) => { var target = link.replace(currentPath, targetPath); fs.readlink(link, function (err, resolvedPath) { if (err) { @@ -184,7 +184,7 @@ function ncp (source, dest, options, callback) { }); } - function checkLink(resolvedPath, target) { + checkLink = (resolvedPath, target) => { if (dereference) { resolvedPath = path.resolve(basePath, resolvedPath); } @@ -209,7 +209,7 @@ function ncp (source, dest, options, callback) { }); } - function makeLink(linkPath, target) { + makeLink = (linkPath, target) => { fs.symlink(linkPath, target, function (err) { if (err) { return onError(err); @@ -218,7 +218,7 @@ function ncp (source, dest, options, callback) { }); } - function isWritable(path, done) { + isWritable = (path, done) => { fs.lstat(path, function (err) { if (err) { if (err.code === 'ENOENT') return done(true); @@ -228,7 +228,7 @@ function ncp (source, dest, options, callback) { }); } - function onError(err) { + onError = (err) => { if (options.stopOnError) { return cback(err); } @@ -247,7 +247,7 @@ function ncp (source, dest, options, callback) { return cb(); } - function cb(skipped) { + cb = (skipped) => { if (!skipped) running--; finished++; if ((started === finished) && (running === 0)) {