fs-mkdirp
v3.0.1
Published
node fs mkdir -p
Downloads
5
Readme
fs-mkdirp
node fs mkdir -p
Demo
npm start
Result:
- mkdirp
- demo
- dir
- subdir
- dir
- demo
Usage
var $mkdirp = require( "./fs-mkdirp-p" );
Promise
$mkdirp( "./directory/dir/subdir" ).then(function( results ) {
var error = results.error;
var log = results.log;
if( !error ) {
// do something
}
else {
// error
}
log.forEach(function( result ) {
console.log( result );
});
});
Result:
- mkdirp
- directory
- dir
- subdir
- dir
- directory
var mkdirp = require( "./fs-mkdirp" );
Callback
mkdirp( "./directory/dir/subdir", function( error, results ) {
if( !error ) {
// do something
}
else {
// error
}
results.forEach(function( result ) {
console.log( result );
});
});
Result:
- mkdirp
- directory
- dir
- subdir
- dir
- directory
path
string
var path;
path = "directory/dir/subdir";
path = "directory/dir/subdir/";
path = "/directory/dir/subdir";
path = "./directory/dir/subdir";
mkdirp( path );
Result:
- mkdirp
- directory
- dir
- subdir
- dir
- directory
var path = "../directory/dir/subdir";
mkdirp( path );
Result:
- parent
- mkdirp
- directory
- dir
- subdir
- dir
callback
function
var mkdirp = require( "./fs-mkdirp.js" );
var path = "../../directory/dir/subdir";
var callback = function( error, results ) {
if( !error ) {
results.forEach(function( result ) {
console.log( result );
});
}
else {
results.forEach(function( result ) {
console.log( result );
});
}
};
mkdirp( path, callback );
Result:
- parent
- parent
- mkdirp
- directory
- dir
- subdir
- dir
- parent