Skip to content

Commit 64b81e3

Browse files
author
liuyt
committed
修改递归创建文件夹BUG
1 parent 3113b2b commit 64b81e3

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

lib/utils.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,18 @@ let mkdirSync = function (dirpath, mode) {
1414
if (!fs.existsSync(dirpath)) {
1515
let pathtmp;
1616
dirpath.split(/[/\\]/).forEach(function (dirname) {
17+
if (dirname === '') {
18+
if (!pathtmp) {
19+
pathtmp += '/';
20+
}
21+
return false;
22+
}
1723
if (pathtmp) {
1824
pathtmp = path.join(pathtmp, dirname);
1925
} else {
2026
pathtmp = dirname;
2127
}
28+
2229
if (!fs.existsSync(pathtmp)) {
2330
if (!fs.mkdirSync(pathtmp, mode)) {
2431
return false;
@@ -28,7 +35,7 @@ let mkdirSync = function (dirpath, mode) {
2835
}
2936
return true;
3037
} catch (e) {
31-
log.error("create director fail! path=" + dirpath + " errorMsg:" + e);
38+
console.error("create director fail! path=" + dirpath + " errorMsg:" + e);
3239
return false;
3340
}
3441
}

0 commit comments

Comments
 (0)