summaryrefslogtreecommitdiff
path: root/packages/core/src/utils/gitIgnoreParser.ts
diff options
context:
space:
mode:
authorTommaso Sciortino <[email protected]>2025-07-25 00:15:41 -0700
committerGitHub <[email protected]>2025-07-25 07:15:41 +0000
commit5d4b02ca85e2e6427b68f27a01659a9f0db66d74 (patch)
tree704fbad8db124f0146468d3f7fc409de2b241249 /packages/core/src/utils/gitIgnoreParser.ts
parent1d7eb0d25078f34b37a0cbd8a6a869d3e61a2602 (diff)
Upgrade test to work on windows. (#4815)
Diffstat (limited to 'packages/core/src/utils/gitIgnoreParser.ts')
-rw-r--r--packages/core/src/utils/gitIgnoreParser.ts19
1 files changed, 5 insertions, 14 deletions
diff --git a/packages/core/src/utils/gitIgnoreParser.ts b/packages/core/src/utils/gitIgnoreParser.ts
index 50018bb7..f2422a92 100644
--- a/packages/core/src/utils/gitIgnoreParser.ts
+++ b/packages/core/src/utils/gitIgnoreParser.ts
@@ -57,24 +57,15 @@ export class GitIgnoreParser implements GitIgnoreFilter {
}
isIgnored(filePath: string): boolean {
- const relativePath = path.isAbsolute(filePath)
- ? path.relative(this.projectRoot, filePath)
- : filePath;
+ const resolved = path.resolve(this.projectRoot, filePath);
+ const relativePath = path.relative(this.projectRoot, resolved);
- if (
- relativePath === '' ||
- relativePath.startsWith('..') ||
- relativePath === '/' ||
- relativePath.startsWith('/')
- ) {
+ if (relativePath === '' || relativePath.startsWith('..')) {
return false;
}
- let normalizedPath = relativePath.replace(/\\/g, '/');
- if (normalizedPath.startsWith('./')) {
- normalizedPath = normalizedPath.substring(2);
- }
-
+ // Even in windows, Ignore expects forward slashes.
+ const normalizedPath = relativePath.replace(/\\/g, '/');
return this.ig.ignores(normalizedPath);
}