Upgrade test to work on windows. (#4815)

This commit is contained in:
Tommaso Sciortino
2025-07-25 00:15:41 -07:00
committed by GitHub
parent 1d7eb0d250
commit 5d4b02ca85
2 changed files with 75 additions and 78 deletions

View File

@@ -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);
}