// 创建 /tmp/a/apple 目录,无论是否存在 /tmp 和 /tmp/a 目录。
var fs = require('fs');
var path = require('path');
var fliename = path.join(__dirname,'./test/a/apple');
fs.mkdir(fliename,{recursive:true},(err)=>{
if(err){
throw err;
}else{
console.log('ok!');
}
});
来自官网的: 异步地创建目录。 除了可能的异常,完成回调没有其他参数。
可选的 options 参数可以是指定模式(权限和粘滞位)的整数,也可以是具有 mode 属性和 recursive
属性(指示是否应创建父文件夹)的对象。