diff --git a/commands/compile.js b/commands/compile.js index 468c051..ce46151 100644 --- a/commands/compile.js +++ b/commands/compile.js @@ -232,7 +232,7 @@ function generateCompileFn(fileNameSansExtension, extension, compilerOptions, // consolidate-build will take care of picking which compiler to use; // simply use the file extension as a key - return utils.mkdirRecursive(directory) + return utils.mkdirRecursive(pathLib.dirname(directory + '/' + fileDisplay)) .then(function() { return q.ncall(build[extension], build[extension], fileName, options); }) diff --git a/lib/utils.js b/lib/utils.js index 59e8e5c..d8c0dbc 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -219,7 +219,14 @@ exports.mkdirRecursive = function(path) { var promises = areDirectories.map(function(isDirectory, index) { // create any directories that don't exist if (!isDirectory) { - return q.ncall(fs.mkdir, fs, directories[index]); + return q.ncall(fs.mkdir, fs, directories[index]) + .fail(function(error) { + // errno 47 means directory already exists, so there is no need + // to throw any error, as what we're trying to do has been done + if (error.errno !== 47) { + throw error; + } + }); } });