Skip to content

Commit 4aa35f4

Browse files
committed
Override base dir for .git/info/exclude (resolves #1129)
1 parent bbf67dd commit 4aa35f4

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

packages/knip/src/util/glob-core.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,10 @@ export const findAndParseGitignores = async (cwd: string) => {
6464
return false;
6565
};
6666

67-
const addFile = (filePath: string) => {
67+
const addFile = (filePath: string, baseDir?: string) => {
6868
gitignoreFiles.push(relative(cwd, filePath));
6969

70-
const dir = dirname(toPosix(filePath));
70+
const dir = baseDir ?? dirname(toPosix(filePath));
7171
const base = relative(cwd, dir);
7272
const ancestor = base.startsWith('..') ? `${relative(dir, cwd)}/` : undefined;
7373

@@ -126,7 +126,7 @@ export const findAndParseGitignores = async (cwd: string) => {
126126

127127
findAncestorGitignoreFiles(cwd).forEach(addFile);
128128

129-
if (isFile('.git/info/exclude')) addFile('.git/info/exclude');
129+
if (isFile('.git/info/exclude')) addFile('.git/info/exclude', cwd);
130130

131131
const entryFilter = (entry: Entry) => {
132132
if (entry.dirent.isFile() && entry.name === '.gitignore') {

0 commit comments

Comments
 (0)