index.js
function mkdir(dirname, options = {}) {
  if (fs.existsSync(dirname)) return;
  assert.equal(typeof dirname, 'string', 'expected dirname to be a string');
  let opts = Object.assign({ cwd: process.cwd(), fs }, options);
  let mode = opts.mode || 0o777 & ~process.umask();
  let segs = path.relative(opts.cwd, dirname).split(path.sep);
  let make = dir => !exists(dir, opts) && fs.mkdirSync(dir, mode);
  for (let i = 0; i <= segs.length; i++) {
    try {
      make((dirname = path.join(opts.cwd, ...segs.slice(0, i))));
    } catch (err) {
      handleError(dirname, opts)(err);
    }
  }
  return dirname;
}
function mkdir(dirname, options = {}) {
  if (fs.existsSync(dirname)) return;
  assert.equal(typeof dirname, 'string', 'expected dirname to be a string');
  let opts = Object.assign({ cwd: process.cwd(), fs }, options);
  let mode = opts.mode || 0o777 & ~process.umask();
  let segs = path.relative(opts.cwd, dirname).split(path.sep);
  let make = dir => !exists(dir, opts) && fs.mkdirSync(dir, mode);
  for (let i = 0; i <= segs.length; i++) {
    try {
      make((dirname = path.join(opts.cwd, ...segs.slice(0, i))));
    } catch (err) {
      handleError(dirname, opts)(err);
    }
  }
  return dirname;
}
function mkdir ( dirname , options = { } ) { if ( fs . existsSync ( dirname ) ) return ; assert . equal ( typeof dirname , 'string' , 'expected dirname to be a string' ) ; let opts = Object . assign ( { cwd : process . cwd ( ) , fs } , options ) ; let mode = opts . mode || 0o777 & ~ process . umask ( ) ; let segs = path . relative ( opts . cwd , dirname ) . split ( path . sep ) ; let make = dir => ! exists ( dir , opts ) && fs . mkdirSync ( dir , mode ) ; for ( let i = 0 ; i <= segs . length ; i ++ ) { try { make ( ( dirname = path . join ( opts . cwd , ... segs . slice ( 0 , i ) ) ) ) ; } catch ( err ) { handleError ( dirname , opts ) ( err ) ; } } return dirname ; }
Create a directory and any intermediate directories that might exist.
Create a directory and any intermediate directories that might exist .