Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updated README.MD #135

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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!');
}
});
```

Expand Down
30 changes: 15 additions & 15 deletions lib/ncp.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
var fs = require('fs'),
path = require('path');
var path = require('path');

module.exports = ncp;
ncp.ncp = ncp;
Expand Down Expand Up @@ -31,7 +31,7 @@ function ncp (source, dest, options, callback) {

startCopy(currentPath);

function startCopy(source) {
startCopy = (source) => {
started++;
if (filter) {
if (filter instanceof RegExp) {
Expand All @@ -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 () {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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 });

Expand All @@ -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);
Expand All @@ -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) {
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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) {
Expand All @@ -184,7 +184,7 @@ function ncp (source, dest, options, callback) {
});
}

function checkLink(resolvedPath, target) {
checkLink = (resolvedPath, target) => {
if (dereference) {
resolvedPath = path.resolve(basePath, resolvedPath);
}
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -228,7 +228,7 @@ function ncp (source, dest, options, callback) {
});
}

function onError(err) {
onError = (err) => {
if (options.stopOnError) {
return cback(err);
}
Expand All @@ -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)) {
Expand Down