Skip to content
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
15 changes: 7 additions & 8 deletions lib/ncp.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
var fs = require('fs'),
path = require('path'),
util = require('util');
util = require('util'),
mkdirp = require('mkdirp');

const modern = /^v0\.1\d\.\d+/.test(process.version);

Expand Down Expand Up @@ -35,7 +36,7 @@ function ncp (source, dest, options, callback) {
limit = (limit < 1) ? 1 : (limit > 512) ? 512 : limit;

startCopy(currentPath);

function startCopy(source) {
started++;
if (filter) {
Expand Down Expand Up @@ -118,10 +119,10 @@ function ncp (source, dest, options, callback) {
function copyFile(file, target) {
var readStream = fs.createReadStream(file.name),
writeStream = fs.createWriteStream(target, { mode: file.mode });

readStream.on('error', onError);
writeStream.on('error', onError);

if(transform) {
transform(readStream, writeStream, file);
} else {
Expand Down Expand Up @@ -159,7 +160,7 @@ function ncp (source, dest, options, callback) {
}

function mkDir(dir, target) {
fs.mkdir(target, dir.mode, function (err) {
mkdirp(target, dir.mode, function (err) {
if (err) {
return onError(err);
}
Expand Down Expand Up @@ -246,7 +247,7 @@ function ncp (source, dest, options, callback) {
if (typeof errs.write === 'undefined') {
errs.push(err);
}
else {
else {
errs.write(err.stack + '\n\n');
}
return cb();
Expand All @@ -262,5 +263,3 @@ function ncp (source, dest, options, callback) {
}
}
}


59 changes: 31 additions & 28 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,30 +1,33 @@
{
"name" : "ncp",
"version" : "1.0.1",
"author": "AvianFlu <charlie@charlieistheman.com>",
"description" : "Asynchronous recursive file copy utility.",
"bin": {
"ncp": "./bin/ncp"
},
"devDependencies" : {
"mocha": "1.15.x",
"rimraf" : "1.0.x",
"read-dir-files" : "0.0.x"
},
"main": "./lib/ncp.js",
"repository" : {
"type" : "git",
"url" : "https://github.com/AvianFlu/ncp.git"
},
"keywords" : [
"cli",
"copy"
],
"license" : "MIT",
"engine" : {
"node" : ">=0.8"
},
"scripts" : {
"test": "mocha -R spec"
}
"name": "ncp",
"version": "1.0.1",
"author": "AvianFlu <charlie@charlieistheman.com>",
"description": "Asynchronous recursive file copy utility.",
"bin": {
"ncp": "./bin/ncp"
},
"devDependencies": {
"mocha": "1.15.x",
"rimraf": "1.0.x",
"read-dir-files": "0.0.x"
},
"main": "./lib/ncp.js",
"repository": {
"type": "git",
"url": "https://github.com/AvianFlu/ncp.git"
},
"keywords": [
"cli",
"copy"
],
"license": "MIT",
"engine": {
"node": ">=0.8"
},
"scripts": {
"test": "mocha -R spec"
},
"dependencies": {
"mkdirp": "^0.5.0"
}
}