code: function mkdirParents(dirPath) {
    dirPath.split(/\/|\\/).reduce(function(parents, dir) {
      var path = pathUtil.resolve((parents += dir + pathUtil.sep)); // normalize
      if (!fs.existsSync(path)) {
        fs.mkdirSync(path);
      } else if (!fs.statSync(path).isDirectory()) {
        throw new Error('Non directory already exists: ' + path);
      }
      return parents;
    }, '');
  }
docs: mkdir -p