diff --git a/lib/ncp.js b/lib/ncp.js index b5c4f93..96eed47 100644 --- a/lib/ncp.js +++ b/lib/ncp.js @@ -1,8 +1,6 @@ var fs = require('fs'), path = require('path'); -const modern = /^v0\.1\d\.\d+/.test(process.version); - module.exports = ncp; ncp.ncp = ncp; @@ -24,8 +22,6 @@ function ncp (source, dest, options, callback) { modified = options.modified, dereference = options.dereference, errs = null, - eventName = modern ? 'finish' : 'close', - defer = modern ? setImmediate : process.nextTick, started = 0, finished = 0, running = 0, @@ -55,7 +51,7 @@ function ncp (source, dest, options, callback) { function getStats(source) { var stat = dereference ? fs.stat : fs.lstat; if (running >= limit) { - return defer(function () { + return setImmediate(function () { getStats(source); }); } @@ -128,7 +124,7 @@ function ncp (source, dest, options, callback) { readStream.pipe(writeStream); }); } - writeStream.once(eventName, function() { + writeStream.once('finish', function() { if (modified) { //target file modified date sync. fs.utimesSync(target, file.atime, file.mtime);