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

Switch package to use mkdirp so that files can be copied into a ... #76

Open
wants to merge 1 commit 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
5 changes: 3 additions & 2 deletions lib/ncp.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
var fs = require('fs'),
path = require('path');
path = require('path'),
mkdirp = require('mkdirp');

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

Expand Down Expand Up @@ -158,7 +159,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
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"ncp": "./bin/ncp"
},
"devDependencies" : {
"mkdirp": "0.5.x",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mkdirp should be added as a regular dependency, not just a dev dependency

"mocha": "1.15.x",
"rimraf" : "1.0.x",
"read-dir-files" : "0.0.x"
Expand Down
22 changes: 22 additions & 0 deletions test/ncp.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,4 +194,26 @@ describe('ncp', function () {
});

});

describe('copies into folder missing parent', function() {
var fixtures = path.join(__dirname, 'regular-fixtures'),
src = path.join(fixtures, 'src'),
out = path.join(fixtures, 'dne/dne');
outParent = path.join(fixtures, 'dne');

before(function (cb) {
rimraf(outParent, function() {
ncp(src, out, cb);
});
});
it('files are copied correctly', function (cb) {
readDirFiles(src, 'utf8', function (srcErr, srcFiles) {
readDirFiles(out, 'utf8', function (outErr, outFiles) {
assert.ifError(srcErr);
assert.deepEqual(srcFiles, outFiles);
cb();
});
});
});
});
});