Skip to content

Commit 118e02e

Browse files
committed
Add env var utils function for tests
1 parent 2bd56c6 commit 118e02e

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

tests/utils.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,3 +190,17 @@ export function fileLoader(...path: string[]) {
190190
export function quartoDevCmd(): string {
191191
return Deno.build.os === "windows" ? "quarto.cmd" : "quarto";
192192
}
193+
194+
export function setEnvVar(name: string, value: string): string | undefined {
195+
const originalValue = Deno.env.get(name);
196+
Deno.env.set(name, value);
197+
return originalValue;
198+
}
199+
200+
export function restoreEnvVar(name: string, originalValue: string | undefined): void {
201+
if (originalValue !== undefined) {
202+
Deno.env.set(name, originalValue);
203+
} else {
204+
Deno.env.delete(name);
205+
}
206+
}

0 commit comments

Comments
 (0)