Fix env var handling for MacOs
This commit is contained in:
15
src/ipc/utils/read_env.ts
Normal file
15
src/ipc/utils/read_env.ts
Normal 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];
|
||||
}
|
||||
Reference in New Issue
Block a user