Skip to content

Commit 6063828

Browse files
committed
Workaround PATH casing issues on Windows
1 parent 611b1e2 commit 6063828

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

lib/testing-utils.js

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/testing-utils.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/testing-utils.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,16 @@ export function setupTests(test: TestFn<any>) {
6363
t.context.stderrWrite = processStderrWrite;
6464
process.stderr.write = wrapOutput(t.context) as any;
6565

66+
// Workaround an issue in tests where the case insensitivity of the `$PATH`
67+
// environment variable on Windows isn't preserved, i.e. `process.env.PATH`
68+
// is not the same as `process.env.Path`.
69+
const pathKeys = Object.keys(process.env).filter(
70+
(k) => k.toLowerCase() === "path"
71+
);
72+
if (pathKeys.length > 0) {
73+
process.env.PATH = process.env[pathKeys[0]];
74+
}
75+
6676
// Many tests modify environment variables. Take a copy now so that
6777
// we reset them after the test to keep tests independent of each other.
6878
// process.env only has strings fields, so a shallow copy is fine.

0 commit comments

Comments
 (0)