Merge pull request #192 from phated/master

Implement `mkdir -p` for `--output` build option.

Former-commit-id: cb7a6753d15f495a1ab8b0016edd34d5626727de
This commit is contained in:
John-David Dalton
2013-02-23 22:55:18 -08:00
2 changed files with 12 additions and 1 deletions

View File

@@ -1513,6 +1513,14 @@
var outputPath = options.reduce(function(result, value, index) {
if (/-o|--output/.test(value)) {
result = options[index + 1];
var cwd = process.cwd();
path.dirname(result).split(path.sep).forEach(function(pathSegment){
try {
fs.mkdirSync(pathSegment);
} catch(err){}
process.chdir(pathSegment);
});
process.chdir(cwd);
result = path.join(fs.realpathSync(path.dirname(result)), path.basename(result));
}
return result;