Skip to content

Commit 15ab420

Browse files
fix(#329): normalize testtools workspace root path for win32 (#330)
1 parent 9138da6 commit 15ab420

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

packages/testtools/src/schema.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,17 @@ export function run(cmd: string, env?: Record<string, string>, cwd?: string) {
3434
});
3535
}
3636

37+
function normalizePath(p: string) {
38+
return p ? p.split(path.sep).join(path.posix.sep) : p;
39+
}
40+
3741
export function getWorkspaceRoot(start: string) {
38-
let curr = start;
42+
let curr = normalizePath(start);
3943
while (curr && curr !== '/') {
4044
if (fs.existsSync(path.join(curr, 'pnpm-workspace.yaml'))) {
4145
return curr;
4246
} else {
43-
curr = path.dirname(curr);
47+
curr = normalizePath(path.dirname(curr));
4448
}
4549
}
4650
return undefined;
@@ -93,9 +97,11 @@ export async function loadSchema(
9397
const { name: projectRoot } = tmp.dirSync();
9498

9599
const root = getWorkspaceRoot(__dirname);
100+
96101
if (!root) {
97102
throw new Error('Could not find workspace root');
98103
}
104+
99105
console.log('Workspace root:', root);
100106

101107
const pkgContent = fs.readFileSync(path.join(__dirname, 'package.template.json'), { encoding: 'utf-8' });

0 commit comments

Comments
 (0)