How to use the @poppinss/utils.fsReadAll function in @poppinss/utils

To help you get started, we’ve selected a few @poppinss/utils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github adonisjs / ace / src / utils / listDirectoryFiles.ts View on Github external
export function listDirectoryFiles (
  scanDirectory: string,
  appRoot: string,
  filterFn?: CommandsListFilterFn,
): string[] {
  return fsReadAll(scanDirectory)
    .filter((name) => !name.endsWith('.json')) // remove .json files
    .map((name) => {
      const relativePath = relative(appRoot, join(scanDirectory, name))
      return slash(relativePath.startsWith('../') ? relativePath : `./${relativePath}`)
    })
    .filter((name) => {
      if (typeof (filterFn) === 'function') {
        return filterFn(name)
      }

      return Array.isArray(filterFn) ? !filterFn.includes(name) : true
    })
}

@poppinss/utils

Handy utilities for repetitive work

MIT
Latest version published 2 months ago

Package Health Score

79 / 100
Full package analysis