diff --git a/lib/ncp.js b/lib/ncp.js index bc25a05..104cece 100644 --- a/lib/ncp.js +++ b/lib/ncp.js @@ -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); @@ -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) { @@ -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 { @@ -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); } @@ -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(); @@ -262,5 +263,3 @@ function ncp (source, dest, options, callback) { } } } - - diff --git a/package.json b/package.json index 325a552..c4f2a5e 100644 --- a/package.json +++ b/package.json @@ -1,30 +1,33 @@ { - "name" : "ncp", - "version" : "1.0.1", - "author": "AvianFlu ", - "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 ", + "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" + } }