Skip to content

Commit 21da7b5

Browse files
committed
test(e2e): robust .env.local loader for VS Code extension host tests
1 parent 6aed669 commit 21da7b5

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

apps/vscode-e2e/src/suite/index.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,17 @@ export async function run() {
2626
for (const rawLine of content.split("\n")) {
2727
const line = rawLine.trim()
2828
if (!line || line.startsWith("#")) continue
29-
const match = line.match(/^\s*([A-Za-z_][A-Za-z0-9_]*)\s*=\s*(.*)\s*$/)
30-
if (!match) continue
31-
const key = match[1]
32-
let val = match[2]
29+
const m = /^\s*([A-Za-z_][A-Za-z0-9_]*)\s*=\s*(.*)\s*$/.exec(line)
30+
if (!m) continue
31+
const key: string = m[1] ?? ""
32+
let val: string = m[2] ?? ""
3333
// Strip surrounding quotes if present
3434
if ((val.startsWith('"') && val.endsWith('"')) || (val.startsWith("'") && val.endsWith("'"))) {
3535
val = val.slice(1, -1)
3636
}
37-
if (!process.env[key]) process.env[key] = val
37+
if (key && !(key in process.env)) {
38+
;(process.env as Record<string, string>)[key] = val
39+
}
3840
}
3941
} catch {
4042
// ignore env load errors; tests may still pass without API calls

0 commit comments

Comments
 (0)