a lightweight package making directory recursively and asynchronously in node.js
var mkdirs = require('util-mkdirs')
//absolute path
mkdirs('/path/to/dir', (err, fp)=>{
if(err){
console.log(err)
return
}
console.log(fp)
//do something else
})
//relative path
mkdirs('./path/to/dir', (err, fp)=>{
if(err){
console.log(err)
return
}
console.log(fp)
//do something else
})
npm i util-mkdirs --save
var mkdirs = require('util-mkdirs')
mkdirs(dirpath [,mode] [,callback])
- dirpath: [required] {string|buffer} relative or absolute path
- mode: [options] {string|number} default 777 which will finally convert to an oct number
- callback: [options] {function} a function with two paras:
err
,fp
. if everything is fine,err
will benull
andfp
refers to the dirpath you created.
npm install
npm test
make sure you have the permission to create the aimed directory. Once the directory exist already, nothing will happen.