Skip to content

Commit e049fda

Browse files
committed
fix: make directory exclusion case-insensitive for cross-platform compatibility
The shouldProcessFile function used case-sensitive path comparisons, which could fail to exclude directories like NODE_MODULES or Node_Modules on case-insensitive file systems (Windows/macOS). - Convert file paths to lowercase before pattern matching - Update tests to verify case-insensitive behavior - Ensures consistent directory exclusion across all platforms
1 parent 51dd734 commit e049fda

2 files changed

Lines changed: 11 additions & 6 deletions

File tree

src/src/file-watcher.test.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,18 @@ describe("File Watcher Functions", () => {
4949
expect(shouldProcessFile("C:/project/.git/config")).toBe(false);
5050
});
5151

52-
test("handles case sensitivity in directory names", () => {
52+
test("handles case insensitivity in directory names", () => {
5353
expect(shouldProcessFile("/project/Node_Modules/package/index.js")).toBe(
54-
true
54+
false
55+
);
56+
expect(shouldProcessFile("/project/NODE_MODULES/package/index.js")).toBe(
57+
false
5558
);
56-
expect(shouldProcessFile("/project/.GIT/config")).toBe(true);
57-
expect(shouldProcessFile("/project/.vscode-test/config.json")).toBe(true);
59+
expect(shouldProcessFile("/project/.GIT/config")).toBe(false);
60+
expect(shouldProcessFile("/project/.Git/config")).toBe(false);
61+
expect(shouldProcessFile("/project/DIST/bundle.js")).toBe(false);
5862
expect(shouldProcessFile("/project/.vscode/Settings.json")).toBe(false);
63+
expect(shouldProcessFile("/project/.VSCODE/settings.json")).toBe(false);
5964
});
6065

6166
test("handles root directory and single-level paths", () => {

src/src/file-watcher.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ export const shouldProcessFile = (filePath: string): boolean => {
9494

9595
return !excludePatterns.some(
9696
(pattern) =>
97-
filePath.includes(path.sep + pattern + path.sep) ||
98-
filePath.endsWith(path.sep + pattern)
97+
filePath.toLowerCase().includes(path.sep + pattern + path.sep) ||
98+
filePath.toLowerCase().endsWith(path.sep + pattern)
9999
);
100100
};

0 commit comments

Comments
 (0)