【发布时间】:2018-05-13 17:58:05
【问题描述】:
我目前在我的 node.js 代码中使用 shell.js 的 mkdir -p,它是同步的。 '-p' 在 shell.mkdir 中用于创建具有完整路径的目录,这是 fs.mkdir 无法做到的。
if(fs.existsSync(archivePath + "\\" + site + "\\" + year)){ // check if site folder exists
console.log(archivePath + "\\" + site + "\\" + year + " exists");
}
else {
console.log(archivePath + "\\" + site + "\\" + year + " does not exist... creating full path now");
shell.mkdir('-p' , archivePath + "\\" + site + "\\" + year + "\\" + missionID);
}
如果有人知道如何获得 fs.mkdir 的异步性质和 shell.mkdir('-p', absolutePath) 的递归性质,请一举告诉我。
【问题讨论】:
-
我不确定您要做什么 1) 将
shell.mkdir替换为fs.mkdir+ wrapper 2) 使shell.mkdirasync 3) 别的什么? -
以上任何一个选项都足够了,只要我能够降低核心功能。
标签: javascript node.js asynchronous fs shelljs