Options
All
  • Public
  • Public/Protected
  • All
Menu

filter-scan-dir

Index

Type aliases

ExtrasData: { dirFile: string; ext: string; file: string; fullFile: string; noExt: string; path: string; stat: Dirent | Stats }

type of the 3rd argument for the filter callback

Type declaration

  • dirFile: string

    path to file without cwd: path + file

  • ext: string

    extsion of the file, ie: .js

  • file: string

    name of the file being considered

  • fullFile: string

    full path with cwd + path + file

  • noExt: string

    file name without the extension

  • path: string

    path to the directory being processed that contains the file

  • stat: Dirent | Stats

    result from fs.lstat or readdir

FilterCallback: (file: string, path: string, extras: ExtrasData) => FilterResult

Type declaration

    • filter callback for file or directory entry

      Parameters

      • file: string

        name of the file/dir being considered

      • path: string

        path to the directory containing the file. Not the full path, just the relative path from CWD. It's empty string for the files in the first level directory.

      • extras: ExtrasData

        extras data

      Returns FilterResult

FilterInfo: { formatName?: string; group?: string; skip?: boolean; stop?: boolean }

Info from the filter callback to indicate what to do next

Type declaration

  • Optional formatName?: string

    if not undefined, then use this as the value to add to the output

  • Optional group?: string

    name of the group to add the file or directory (if grouping is enabled)

  • Optional skip?: boolean

    if true then skip the file or directory, else add it

  • Optional stop?: boolean

    stop the scanning and return the result immediately.

FilterResult: boolean | string | FilterInfo

result from the filter callback

  • false or undefined - skip the file or directory
  • true - include the file in the default result
  • string - name of the group to add the file or directory (if grouping is enabled)
  • FilterInfo - see type FilterInfo for details
GroupingOptions: { grouping: true } & Options

options specifically to set grouping flag true to enable grouping of files

GroupingResult: { files: string[] } & Record<string, string[]>

The scanned result if grouping is enabled.

  • The default files group will contain all files not assigned a group
  • All other files with a group will be assigned to that field
Options: { concurrency?: number; cwd?: string; filter?: FilterCallback; filterDir?: FilterCallback; filterExt?: string | string[]; fullStat?: boolean; ignoreExt?: string | string[]; includeDir?: boolean; maxLevel?: number; pathSep?: string; prefix?: string; prependCwd?: boolean; rethrowError?: boolean; sortFiles?: boolean }

Options for filterScanDir

Type declaration

  • Optional concurrency?: number

    for async version only - numer of directories to process concurrently. Default: 50

    • Set this to 0 or 1 to disable concurrent mode

    NOTE: setting this to a very large number, or Infinity, could potentially increase performance very significantly, however, there is a dimishing return and more memory usage, so the default is already fairly good.

  • Optional cwd?: string

    current working directory to start scanning

  • Optional filter?: FilterCallback

    callback to filter files.

  • Optional filterDir?: FilterCallback

    callback to filter directories.

  • Optional filterExt?: string | string[]

    array or string of extensions to include only, apply after ignoreExt

  • Optional fullStat?: boolean

    use fs.lstat to get stat of each file, instead of readir's withFileTypes option.

    • Default: true - for significant performance improvement, set this to false
  • Optional ignoreExt?: string | string[]

    array or string of extensions to ignore. ext must include ., ie: ".js"

  • Optional includeDir?: boolean

    include directories in result

  • Optional maxLevel?: number

    zero base max level of directories to recurse into. Default: Infinity

  • Optional pathSep?: string

    path separator to use to join entries

    • Default: path.posix.sep
    • If you didn't specify this, then cwd is automatically converted to use /.
  • Optional prefix?: string

    prefix to add to the paths to scan. It's applied after cwd.

    • The prefix will be in the resulting paths. Useful if you want to scan a dir further down from cwd but you don't want to prepend CWD to the resulting paths.
  • Optional prependCwd?: boolean

    prepend CWD to paths returned

  • Optional rethrowError?: boolean

    set to true to throw errors instead of ignoring them

  • Optional sortFiles?: boolean

    sort files from each dir

Functions

Generated using TypeDoc