Skip to content

Commit

Permalink
fixup: add mkdirp
Browse files Browse the repository at this point in the history
  • Loading branch information
Trott committed Apr 8, 2016
1 parent 2d11421 commit 9110975
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion test/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,35 @@ function rmdirSync(p, originalEr) {
}
}

function mkdirp(p, made) {
if (!made)
made = null;

try {
fs.mkdirSync(p);
made = made || p;
} catch (err0) {
if (err0.code === 'ENOENT') {
made = mkdirp(path.dirname(p), made);
mkdirp(p, made);
return made;
}

var stat;
try {
stat = fs.statSync(p);
} catch (err1) {
throw err0;
}
if (!stat.isDirectory())
throw err0;
}
return made;
}

exports.refreshTmpDir = function() {
rimrafSync(exports.tmpDir);
fs.mkdirSync(exports.tmpDir);
mkdirp(exports.tmpDir);
};

if (process.env.TEST_THREAD_ID) {
Expand Down

0 comments on commit 9110975

Please sign in to comment.