Skip to content

Commit 0b857bf

Browse files
authored
fix: drive letter sensitivity on windows (#50)
Fixes #49
1 parent 730e4af commit 0b857bf

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
- Fix bailing multiple configs on first failure (fixes [#44](https://github.com/microsoft/vscode-test-cli/issues/44))
66
- Fix extension install on Windows on modern Node versions (fixes [#43](https://github.com/microsoft/vscode-test-cli/issues/43))
7+
- Normalize casing in paths (fixes [#49](https://github.com/microsoft/vscode-test-cli/issues/49))
78

89
## 0.0.9 - 2024-03-04
910

src/runner.cts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export async function run() {
2727
const required: { mochaGlobalSetup?: () => unknown; mochaGlobalTeardown?: () => unknown }[] = [
2828
...preload,
2929
...ensureArray(mochaOpts.require),
30-
].map((f) => require(f));
30+
].map((f) => require(normalizeCasing(f)));
3131

3232
// currently `require` only seems to take effect for parallel runs, but remove
3333
// the option in case it's supported for serial runs in the future since we're
@@ -39,7 +39,7 @@ export async function run() {
3939
}
4040

4141
for (const file of files) {
42-
mocha.addFile(file);
42+
mocha.addFile(normalizeCasing(file));
4343
}
4444

4545
await new Promise<void>((resolve, reject) =>
@@ -55,5 +55,17 @@ export async function run() {
5555
}
5656
}
5757

58+
const normalizeCasing = (path: string) => {
59+
// Normalize to lower-case drive letter to avoid path sensitivity in the loader
60+
// duplicating imports. VS Code normalizes to lower case drive letters in its
61+
// URIs, so do the same here
62+
// https://github.com/microsoft/vscode/blob/032c1b75447ade317715c3d2a82c2d9cd3e55dde/src/vs/base/common/uri.ts#L181-L185
63+
if (process.platform === 'win32' && path.match(/^[A-Z]:/)) {
64+
return path[0].toLowerCase() + path.slice(1);
65+
}
66+
67+
return path;
68+
};
69+
5870
const ensureArray = <T,>(value: T | T[] | undefined): T[] =>
5971
value ? (Array.isArray(value) ? value : [value]) : [];

0 commit comments

Comments
 (0)