Using original existence check with mkdirp call on failure

This commit is contained in:
FredyC
2013-08-01 17:03:32 +02:00
parent 457cdfde26
commit e644f7244d
2 changed files with 14 additions and 5 deletions

View File

@@ -427,11 +427,18 @@
});
}
};
return mkdirp(jsDir, function(err) {
if (!err) {
return exists(jsDir, function(itExists) {
var _this = this;
if (itExists) {
return compile();
} else {
return exec("mkdir -p " + jsDir, compile);
return mkdirp(jsDir, function(err) {
if (err) {
printLine("Error while creating dir " + jsDir + ": " + err);
exec("mkdir -p " + jsDir);
}
return compile();
});
}
});
};

View File

@@ -284,8 +284,10 @@ writeJs = (base, sourcePath, js, jsPath, generatedSourceMap = null) ->
fs.writeFile sourceMapPath, generatedSourceMap, (err) ->
if err
printLine "Could not write source map: #{err.message}"
mkdirp jsDir, (err) ->
unless err then compile() else exec "mkdir -p #{jsDir}", compile
exists jsDir, (itExists) ->
if itExists then compile() else mkdirp jsDir, (err) =>
if err then printLine "Error while creating dir #{jsDir}: #{err}"; exec "mkdir -p #{jsDir}"
compile()
# Convenience for cleaner setTimeouts.
wait = (milliseconds, func) -> setTimeout func, milliseconds