resources/nodejs/bare-imports.js
// Ignore files and directories whose basenames are keys in ignored.
Ignore files and directories whose basenames are keys in ignored.
Ignore files and directories whose basenames are keys in ignored .
async function walkTree({ directory, callback, ignored }) {
  const dirents = (await util.promisify(fs.readdir)(directory, {
    withFileTypes: true
  })).filter(d => !ignored[d.name]);
  const fromFilesP = Promise.all(
    dirents
      .filter(d => d.isFile() && d.name.match(/\.[jt]sx?$/))
      .map(async d => callback(path.join(directory, d.name)))
  );
  const fromDirectoriesP = Promise.all(
    dirents
      .filter(d => d.isDirectory())
      .map(d =>
        walkTree({ directory: path.join(directory, d.name), callback, ignored })
      )
  );
  const fromFiles = await fromFilesP;
  const fromDirectories = await fromDirectoriesP;
  fromDirectories.push(fromFiles);
  return [].concat.apply([], fromDirectories);
}
async function walkTree ( { directory , callback , ignored } ) { const dirents = ( await util . promisify ( fs . readdir ) ( directory , { withFileTypes : true } ) ) . filter ( d => ! ignored [ d . name ] ) ; const fromFilesP = Promise . all ( dirents . filter ( d => d . isFile ( ) && d . name . match ( / \.[jt]sx?$ / ) ) . map ( async d => callback ( path . join ( directory , d . name ) ) ) ) ; const fromDirectoriesP = Promise . all ( dirents . filter ( d => d . isDirectory ( ) ) . map ( d => walkTree ( { directory : path . join ( directory , d . name ) , callback , ignored } ) ) ) ; const fromFiles = await fromFilesP ; const fromDirectories = await fromDirectoriesP ; fromDirectories . push ( fromFiles ) ; return [ ] . concat . apply ( [ ] , fromDirectories ) ; }
Ignore files and directories whose basenames are keys in ignored.
Ignore files and directories whose basenames are keys in ignored .
// Does not follow symlinks.