|
9 | 9 | import { PathLike, constants, promises as fs } from 'node:fs'; |
10 | 10 | import { basename, dirname, extname, join, relative } from 'node:path'; |
11 | 11 | import { glob, isDynamicPattern } from 'tinyglobby'; |
| 12 | +import { toPosixPath } from '../../utils/path'; |
12 | 13 |
|
13 | 14 | /* Go through all patterns and find unique list of files */ |
14 | 15 | export async function findTests( |
@@ -59,8 +60,6 @@ export function getTestEntrypoints( |
59 | 60 | ); |
60 | 61 | } |
61 | 62 |
|
62 | | -const normalizePath = (path: string): string => path.replace(/\\/g, '/'); |
63 | | - |
64 | 63 | const removeLeadingSlash = (pattern: string): string => { |
65 | 64 | if (pattern.charAt(0) === '/') { |
66 | 65 | return pattern.substring(1); |
@@ -94,10 +93,10 @@ async function findMatchingTests( |
94 | 93 | projectSourceRoot: string, |
95 | 94 | ): Promise<string[]> { |
96 | 95 | // normalize pattern, glob lib only accepts forward slashes |
97 | | - let normalizedPattern = normalizePath(pattern); |
| 96 | + let normalizedPattern = toPosixPath(pattern); |
98 | 97 | normalizedPattern = removeLeadingSlash(normalizedPattern); |
99 | 98 |
|
100 | | - const relativeProjectRoot = normalizePath(relative(workspaceRoot, projectSourceRoot) + '/'); |
| 99 | + const relativeProjectRoot = toPosixPath(relative(workspaceRoot, projectSourceRoot) + '/'); |
101 | 100 |
|
102 | 101 | // remove relativeProjectRoot to support relative paths from root |
103 | 102 | // such paths are easy to get when running scripts via IDEs |
@@ -125,7 +124,7 @@ async function findMatchingTests( |
125 | 124 |
|
126 | 125 | // normalize the patterns in the ignore list |
127 | 126 | const normalizedIgnorePatternList = ignore.map((pattern: string) => |
128 | | - removeRelativeRoot(removeLeadingSlash(normalizePath(pattern)), relativeProjectRoot), |
| 127 | + removeRelativeRoot(removeLeadingSlash(toPosixPath(pattern)), relativeProjectRoot), |
129 | 128 | ); |
130 | 129 |
|
131 | 130 | return glob(normalizedPattern, { |
|
0 commit comments