index.js
function deleteDirectoryFiles(directory, filter = () => true) {
  return readDirectoryFiles(directory)
    .then((files) => {
      const quietDelete = f => deleteFile(path.join(directory, f)).catch(() => null);
      const deletingFiles = files.filter(filter).map(quietDelete);
      return Promise.all(deletingFiles).then(deleted => deleted.filter(d => d !== null));
    });
}
function deleteDirectoryFiles(directory, filter = () => true) {
  return readDirectoryFiles(directory)
    .then((files) => {
      const quietDelete = f => deleteFile(path.join(directory, f)).catch(() => null);
      const deletingFiles = files.filter(filter).map(quietDelete);
      return Promise.all(deletingFiles).then(deleted => deleted.filter(d => d !== null));
    });
}
function deleteDirectoryFiles ( directory , filter = ( ) => true ) { return readDirectoryFiles ( directory ) . then ( ( files ) => { const quietDelete = f => deleteFile ( path . join ( directory , f ) ) . catch ( ( ) => null ) ; const deletingFiles = files . filter ( filter ) . map ( quietDelete ) ; return Promise . all ( deletingFiles ) . then ( deleted => deleted . filter ( d => d !== null ) ) ; } ) ; }
Delete all the files in a directory, applying an optional filter
@param {string} directory path of the directory to clean
@returns {Promise<array>} resolve with all the files deleted succesfully
Delete all the files in a directory applying an optional filter