function createFolder(folderPath, callback) {
  fs.mkdir(folderPath, (err) => {
    if (!err) {
      return callback();
    }
    if (err.code === 'EEXIST') {
      return callback();
    }
    if (err.code !== 'ENOENT') {
      return callback(err);
    }

    /* Try creating parent folder. */
    createFolder(path.dirname(folderPath), (nestedErr) => {
      if (nestedErr) {
        return callback(nestedErr);
      }

      /* Then try again. */
      return createFolder(folderPath, callback);
    });
  });
}
/**
 * Recursively creates given folder Path
 * @param  {String}   folderPath Path to create.
 * @param  {Function} callback   Callback to fire when operation is complete.
 * @return {undefined}           Nothing.
 */
Recursively creates given folder Path
@param  {String}   folderPath Path to create.
@param  {Function} callback   Callback to fire when operation is complete.
@return {undefined}           Nothing.
Recursively creates given folder Path @param { String } folderPath Path to create . @param { Function } callback Callback to fire when operation is complete . @return { undefined } Nothing .
function createFolder(folderPath, callback) {
  fs.mkdir(folderPath, (err) => {
    if (!err) {
      return callback();
    }
    if (err.code === 'EEXIST') {
      return callback();
    }
    if (err.code !== 'ENOENT') {
      return callback(err);
    }
    createFolder(path.dirname(folderPath), (nestedErr) => {
      if (nestedErr) {
        return callback(nestedErr);
      }
      return createFolder(folderPath, callback);
    });
  });
}
function createFolder ( folderPath , callback ) { fs . mkdir ( folderPath , ( err ) => { if ( ! err ) { return callback ( ) ; } if ( err . code === 'EEXIST' ) { return callback ( ) ; } if ( err . code !== 'ENOENT' ) { return callback ( err ) ; } createFolder ( path . dirname ( folderPath ) , ( nestedErr ) => { if ( nestedErr ) { return callback ( nestedErr ) ; } return createFolder ( folderPath , callback ) ; } ) ; } ) ; }
Recursively creates given folder Path
 @param  {String}   folderPath Path to create.
Recursively creates given folder Path @param { String } folderPath Path to create .
/* Try creating parent folder. */ /* Then try again. */