Skip to content

Commit

Permalink
fix: support undefined process
Browse files Browse the repository at this point in the history
  • Loading branch information
cazala committed Aug 5, 2024
1 parent ffebfd5 commit e5f8142
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,7 @@ export function getDefaultEnv(
* Returns the Env to be used
* @returns Env
*/
export function getEnv(
systemEnvVariables: EnvironmentVariables = process.env
): Env {
export function getEnv(systemEnvVariables?: EnvironmentVariables): Env {
if (typeof window !== 'undefined') {
const envFromQueryParam = getEnvFromQueryParam(window.location)
if (envFromQueryParam) {
Expand All @@ -133,5 +131,12 @@ export function getEnv(
}
}

return getDefaultEnv(systemEnvVariables)
let envVars =
typeof systemEnvVariables === 'undefined' &&
typeof process === 'object' &&
typeof process.env === 'object'
? process.env
: systemEnvVariables

return getDefaultEnv(envVars)
}

0 comments on commit e5f8142

Please sign in to comment.