Recursive create folder - Node.js File

Node.js examples for File:Directory

Description

Recursive create folder

Demo Code


var path = require('path');
var fs = require('fs');
var crypto = require('crypto');


/*sync recursive create folder*/
exports.mkdirSync = function(mkPath){
  var parentPath = path.dirname(mkPath);
  if(!fs.existsSync(parentPath)){
    exports.mkdirSync(parentPath);/*from   w  w w.j  a  v a2  s  . co  m*/
  }
  if(!fs.existsSync(mkPath)){
    fs.mkdirSync(mkPath);
  }
}

Related Tutorials