async function getFilepathsInFolder(dir, recursive = false) {
  const pathsList = await readdir(dir);
  return flatten(
    await Promise.all(
      pathsList.sort().map(async (currentPath) => {
        const currentFile = path.resolve(dir, currentPath);
        const statFile = await stat(currentFile);
        if (statFile && statFile.isDirectory()) {
          if (recursive) {
            return await getFilepathsInFolder(currentFile, true);
          }
          return [];
        }
        return [currentFile];
      })
    )
  );
}
Read a directory,
sorting folders and files by alphabetically order.
Can be browsed recursively.

@param {string} dir
The directory to analyse

@param {boolean} recursive
Browse directory recursively

@returns {Promise<[string]>}
All found files, concatenated to the current dir