index.js
function rmdir(p, reserve) {
  if (!isDirectory(p)) return Promise.resolve();
  return fsReaddir(p).then(files => {
    const promises = files.map(item => {
      const filepath = path.join(p, item);
      if (isDirectory(filepath)) return rmdir(filepath, false);
      return fsUnlink(filepath);
    });
    return Promise.all(promises).then(() => {
      if (!reserve) return fsRmdir(p);
    });
  });
}
function rmdir(p, reserve) {
  if (!isDirectory(p)) return Promise.resolve();
  return fsReaddir(p).then(files => {
    const promises = files.map(item => {
      const filepath = path.join(p, item);
      if (isDirectory(filepath)) return rmdir(filepath, false);
      return fsUnlink(filepath);
    });
    return Promise.all(promises).then(() => {
      if (!reserve) return fsRmdir(p);
    });
  });
}
function rmdir ( p , reserve ) { if ( ! isDirectory ( p ) ) return Promise . resolve ( ) ; return fsReaddir ( p ) . then ( files => { const promises = files . map ( item => { const filepath = path . join ( p , item ) ; if ( isDirectory ( filepath ) ) return rmdir ( filepath , false ) ; return fsUnlink ( filepath ) ; } ) ; return Promise . all ( promises ) . then ( ( ) => { if ( ! reserve ) return fsRmdir ( p ) ; } ) ; } ) ; }
remove dir aync
@param  {String} p       [path]
@param  {Boolean} reserve []
@return {Promise}         []
remove dir aync