Class: FileScanner

FileScanner(rootDir, ignoreProcessor, additionalExtensionsopt)

Scans file system directories while respecting ignore patterns and file extension filters.

Constructor

new FileScanner(rootDir, ignoreProcessor, additionalExtensionsopt)

Constructs a FileScanner instance.

Parameters:
Name Type Attributes Default Description
rootDir string

Root directory to start scanning from.

ignoreProcessor IgnoreProcessor

Instance of IgnoreProcessor to handle ignore patterns.

additionalExtensions Array.<string> <optional>
[]

Additional file extensions to include.

Properties:
Name Type Description
rootDir string

The root directory to start scanning from

ignoreProcessor IgnoreProcessor

Processor for handling ignore patterns

allowedExtensions Array.<string>

List of file extensions to include in scan results

Source:
See:
Example
const scanner = new FileScanner('/path/to/root', ignoreProcessor);
const files = await scanner.scan();

Methods

isAllowedExtension(filename) → {boolean}

Checks if the file has an allowed extension.

Parameters:
Name Type Description
filename string

Name of the file to check.

Source:
Returns:
  • Returns true if the file has an allowed extension; otherwise, false.
Type
boolean

isCommonIgnoredDirectory(dirname) → {boolean}

Checks if the directory name is commonly ignored (e.g., node_modules, .git).

Parameters:
Name Type Description
dirname string

Name of the directory to check.

Source:
Returns:
  • Returns true if the directory is commonly ignored; otherwise, false.
Type
boolean

(async) scan() → {Promise.<Array.<string>>}

Initiates the scanning process.

Source:
Returns:
  • Array of relative file paths that are not ignored.
Type
Promise.<Array.<string>>

(async) traverseDirectory(currentDir, files, parentIgnorePatterns)

Recursively traverses directories to find eligible files.

Parameters:
Name Type Description
currentDir string

Current directory being traversed.

files Array.<string>

Accumulator for eligible file paths.

parentIgnorePatterns Array.<string>

Accumulated ignore patterns from parent directories.

Source: