Fix env var handling for MacOs

This commit is contained in:
Will Chen
2025-04-11 10:33:10 -07:00
parent e0a0212934
commit 6ca060d207
5 changed files with 164 additions and 16 deletions

15
src/ipc/utils/read_env.ts Normal file
View File

@@ -0,0 +1,15 @@
import { shellEnvSync } from "shell-env";
// Need to look up run-time env vars this way
// otherwise it doesn't work as expected in MacOs apps:
// https://github.com/sindresorhus/shell-env
let _env: Record<string, string> | null = null;
export function getEnvVar(key: string) {
// Cache it
if (!_env) {
_env = shellEnvSync();
}
return _env[key];
}