Skip to content

Commit

Permalink
Pass through ignore file options to globby
Browse files Browse the repository at this point in the history
While their use is at this point somewhat dubious (due to performance
issues), that's not a reason we should stop people from using them.

Reference: sindresorhus/globby#50
  • Loading branch information
djmattyg007 committed Jun 12, 2022
1 parent 87db580 commit 283d16e
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/scanner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ export interface ScanOptions {
readonly mdType: MarkdownType;
readonly mdFileExts: ReadonlySet<string>;
readonly globConcurrency: number;
readonly useGitignore: boolean;
readonly ignoreFiles: ReadonlyArray<string>;
}

export interface ScanResult {
Expand All @@ -28,6 +30,8 @@ const scanOptionsDefaults: ScanOptions = {
mdFileExts: mdDefaultFileExts,
caseSensitive: false,
globConcurrency: 0,
useGitignore: false,
ignoreFiles: [],
};

interface GlobOptions extends GlobbyGlobOptions {
Expand Down Expand Up @@ -57,14 +61,17 @@ export async function* scanFiles(
...options,
};

// The intent is clearer with a plain slice.
/* eslint-disable unicorn/prefer-spread */
const globOptions: GlobOptions = {
cwd: mergedOptions.basePath,
// The intent is clearer with a plain slice.
// eslint-disable-next-line unicorn/prefer-spread
ignore: excludeGlobs.slice(),
caseSensitiveMatch: mergedOptions.caseSensitive,
onlyFiles: true,
gitignore: mergedOptions.useGitignore,
ignoreFiles: mergedOptions.ignoreFiles.slice(),
};
/* eslint-enable unicorn/prefer-spread */
if (mergedOptions.globConcurrency > 0) {
globOptions.concurrency = mergedOptions.globConcurrency;
}
Expand Down

0 comments on commit 283d16e

Please sign in to comment.