mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-05-14 01:33:11 +00:00
fix(writer): fix makeDir directory tree bug
This commit is contained in:
parent
031da1f96b
commit
7ec926ff56
1 changed files with 20 additions and 19 deletions
|
|
@ -13,31 +13,32 @@ exports.output = output;
|
||||||
function output(file, content) {
|
function output(file, content) {
|
||||||
var fullPath = pathUtils.join(OUTPUT_DIR,file);
|
var fullPath = pathUtils.join(OUTPUT_DIR,file);
|
||||||
var dir = pathUtils.dirname(fullPath);
|
var dir = pathUtils.dirname(fullPath);
|
||||||
return Q.when(exports.makeDir(dir), function(error) {
|
return Q.when(exports.makeDir(dir), function () {
|
||||||
qfs.write(fullPath, exports.toString(content));
|
return qfs.write(fullPath, exports.toString(content));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
//recursively create directory
|
//recursively create directory
|
||||||
exports.makeDir = function(p) {
|
exports.makeDir = function(p) {
|
||||||
p = pathUtils.normalize(p);
|
p = pathUtils.normalize(p);
|
||||||
var parts = p.split(pathUtils.sep);
|
var parts = p.split(pathUtils.sep);
|
||||||
var path = ".";
|
|
||||||
|
|
||||||
// Recursively rebuild directory structure
|
var makePartialDir = function makePartialDir(path) {
|
||||||
return qfs.exists(p).
|
return qfs.makeDirectory(path).then(function() {
|
||||||
then(function createPart(exists) {
|
if (parts.length) {
|
||||||
if(!exists && parts.length) {
|
return makePartialDir(pathUtils.join(path, parts.shift()));
|
||||||
path = pathUtils.join(path, parts.shift());
|
}
|
||||||
return qfs.exists(path).then(function(exists) {
|
}, function(error) {
|
||||||
if (!exists) {
|
if (error.code !== 'EEXIST') {
|
||||||
return qfs.makeDirectory(path).then(createPart, createPart);
|
throw error;
|
||||||
} else {
|
}
|
||||||
return createPart();
|
if (parts.length) {
|
||||||
}
|
return makePartialDir(pathUtils.join(path, parts.shift()));
|
||||||
});
|
}
|
||||||
}
|
});
|
||||||
});
|
};
|
||||||
|
|
||||||
|
return makePartialDir(pathUtils.join('.', parts.shift()));
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.copyTemplate = function(filename) {
|
exports.copyTemplate = function(filename) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue