Fix lint plugins & tests on Windows

This commit is contained in:
Yury Bondarenko
2024-04-25 11:37:28 +02:00
parent 671e9f172b
commit 145a0a04b6
3 changed files with 22 additions and 15 deletions

View File

@@ -14,3 +14,15 @@ export function match(rangeA: number[], rangeB: number[]) {
export function stringLiteral(value: string): string {
return `'${value}'`;
}
/**
* Transform Windows-style paths into Unix-style paths
*/
export function toUnixStylePath(path: string): string {
// note: we're assuming that none of the directory/file names contain '\' or '/' characters.
// using these characters in paths is very bad practice in general, so this should be a safe assumption.
if (path.includes('\\')) {
return path.replace(/^[A-Z]:\\/, '/').replaceAll('\\', '/');
}
return path;
}