scanner.js
async function tree(dir, files) {
      log.trace.configure({ reading: dir });

      const { filter } = conf;
      const ls = await readdir(dir, conf.options);

      for (let i = 0; i < ls.length; i += 1) {
        const file = path.join(dir, ls[i]);
        if (!filter || filter([file]).length) {
          log.trace.configure({ passed_fitler: file });
          files.push(file);

          // eslint-disable-next-line no-await-in-loop
          if ((await stat(file)).isDirectory()) {
            log.trace.configure({ recursing: file });
            // eslint-disable-next-line no-await-in-loop
            await tree(file, files);
          }
        }
      }

      return files;
    }
async function tree(dir, files) {
      log.trace.configure({ reading: dir });

      const { filter } = conf;
      const ls = await readdir(dir, conf.options);

      for (let i = 0; i < ls.length; i += 1) {
        const file = path.join(dir, ls[i]);
        if (!filter || filter([file]).length) {
          log.trace.configure({ passed_fitler: file });
          files.push(file);

          // eslint-disable-next-line no-await-in-loop
          if ((await stat(file)).isDirectory()) {
            log.trace.configure({ recursing: file });
            // eslint-disable-next-line no-await-in-loop
            await tree(file, files);
          }
        }
      }

      return files;
    }
async function tree ( dir , files ) { log . trace . configure ( { reading : dir } ) ; const { filter } = conf ; const ls = await readdir ( dir , conf . options ) ; for ( let i = 0 ; i < ls . length ; i += 1 ) { const file = path . join ( dir , ls [ i ] ) ; if ( ! filter || filter ( [ file ] ) . length ) { log . trace . configure ( { passed_fitler : file } ) ; files . push ( file ) ; // eslint-disable-next-line no-await-in-loop if ( ( await stat ( file ) ) . isDirectory ( ) ) { log . trace . configure ( { recursing : file } ) ; // eslint-disable-next-line no-await-in-loop await tree ( file , files ) ; } } } return files ; }
Recursively builds a list of files and directories for the specified
directory and all subdirectors - can be optionally filtered.

@param {string} dir - The directory to list (ls)
@param {array} files - The array for appending files/directors
@return {array} The files argument
Recursively builds a list of files and directories for the specified directory and all subdirectors - can be optionally filtered .