Skip to content

Commit 0963c96

Browse files
committedFeb 8, 2024
Use isGitIgnored directly if available, rename fn getter
1 parent 1960a67 commit 0963c96

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed
 

‎packages/knip/src/index.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { PrincipalFactory } from './PrincipalFactory.js';
1111
import { ProjectPrincipal } from './ProjectPrincipal.js';
1212
import { debugLogObject, debugLogArray, debugLog, exportLookupLog } from './util/debug.js';
1313
import { _glob, negate } from './util/glob.js';
14-
import { isGitIgnoredFn } from './util/globby.js';
14+
import { getGitIgnoredFn } from './util/globby.js';
1515
import {
1616
getEntryPathFromManifest,
1717
getPackageNameFromFilePath,
@@ -61,7 +61,7 @@ export const main = async (unresolvedConfiguration: CommandLineOptions) => {
6161
const factory = new PrincipalFactory();
6262
const streamer = new ConsoleStreamer({ isEnabled: isShowProgress });
6363

64-
const isGitIgnored = await isGitIgnoredFn({ cwd, gitignore });
64+
const isGitIgnored = await getGitIgnoredFn({ cwd, gitignore });
6565

6666
streamer.cast('Reading workspace configuration(s)...');
6767

@@ -320,7 +320,7 @@ export const main = async (unresolvedConfiguration: CommandLineOptions) => {
320320
const workspace = chief.findWorkspaceByFilePath(specifierFilePath);
321321
if (workspace) {
322322
const principal = factory.getPrincipalByPackageName(workspace.pkgName);
323-
if (principal && !principal.isGitIgnored(specifierFilePath)) {
323+
if (principal && !isGitIgnored(specifierFilePath)) {
324324
// Defer to outside loop to prevent potential duplicate analysis and/or infinite recursion
325325
specifierFilePaths.add(specifierFilePath);
326326
}

‎packages/knip/src/util/globby.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ export async function globby(patterns: string | string[], options: GlobOptions):
148148
}
149149

150150
/** create a function that should be equivalent to `git check-ignored` */
151-
export async function isGitIgnoredFn(options: Options): Promise<(path: string) => boolean> {
151+
export async function getGitIgnoredFn(options: Options): Promise<(path: string) => boolean> {
152152
cachedIgnores.clear();
153153
if (options.gitignore === false) return () => false;
154154
const gitignore = await _parseFindGitignores(options);

0 commit comments

Comments
 (0)
Please sign in to comment.