really basic version of mkdir -p for -o option

Former-commit-id: 0fb635efd2043ee901c4f4eae7c6670d5b44a068
This commit is contained in:
Blaine Bublitz
2013-02-23 19:37:46 -07:00
parent e2acbee113
commit a99f3f217a
2 changed files with 12 additions and 1 deletions

View File

@@ -1510,6 +1510,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;