Skip to content

Commit ab5b60b

Browse files
committed
Fixed Windows-specific bug in ignore matching
1 parent 5be8473 commit ab5b60b

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

src/core/ignore.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,11 @@ export function isIgnored(absolutePath: string): boolean {
171171
return false;
172172
}
173173

174+
// `ignore` expects POSIX-style separators; Windows uses `\`.
175+
const normalizedPath = relativePath.replace(/\\/g, '/');
176+
174177
try {
175-
return ig.ignores(relativePath);
178+
return ig.ignores(normalizedPath);
176179
} catch {
177180
return false;
178181
}

tests/ignore.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,4 +170,10 @@ describe('isIgnored - edge cases', () => {
170170
// Should not crash on arbitrary absolute paths
171171
expect(() => isIgnored('/tmp/some/random/file.ts')).not.toThrow();
172172
});
173+
174+
it('should handle Windows-style path separators', () => {
175+
if (process.platform !== 'win32') return;
176+
const cwd = process.cwd().replace(/\//g, '\\');
177+
expect(isIgnored(`${cwd}\\node_modules\\foo\\index.js`)).toBe(true);
178+
});
173179
});

0 commit comments

Comments
 (0)