Permalink
Browse files

hybridize isaacs's 5d3f607 patch

  • Loading branch information...
1 parent 282857b commit ab1aa1e68e9a36e6675d584c2330ed3f443cb74b @substack committed Nov 6, 2011
Showing with 3 additions and 5 deletions.
  1. +1 −3 index.js
  2. +2 −2 test/clobber.js
View
@@ -11,7 +11,6 @@ function mkdirP (p, mode, f) {
fs.mkdir(p, mode, function (er) {
if (!er) return cb();
switch (er.code) {
- case 'ENOTDIR':
case 'ENOENT':
mkdirP(path.dirname(p), mode, function (er) {
if (er) cb(er);
@@ -23,8 +22,7 @@ function mkdirP (p, mode, f) {
fs.stat(p, function (er2, stat) {
// if the stat fails, then that's super weird.
// let the original EEXIST be the failure reason.
- if (er2) cb(er);
- else if (!stat.isDirectory()) cb(er)
+ if (er2 || !stat.isDirectory()) cb(er)
else if ((stat.mode & 0777) !== mode) fs.chmod(p, mode, cb);
else cb();
});
View
@@ -30,8 +30,8 @@ test('clobber-pre', function (t) {
test('clobber', function (t) {
t.plan(2);
mkdirp(file, 0755, function (err) {
- t.ok(err)
- t.equal(err.code, 'EEXIST');
+ t.ok(err);
+ t.equal(err.code, 'ENOTDIR');
t.end();
});
});

0 comments on commit ab1aa1e

Please sign in to comment.