-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: fix internal types and expose
EnvObject
- Loading branch information
Showing
4 changed files
with
11 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
export function toBoolean(val) { | ||
export function toBoolean(val: boolean | string | undefined) { | ||
return val ? val !== "false" : false; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,28 @@ | ||
import { env } from "./env"; | ||
import { EnvObject, env } from "./env"; | ||
|
||
export interface Process | ||
extends Partial<Omit<typeof globalThis.process, "versions">> { | ||
env: Record<string, string | undefined>; | ||
env: EnvObject; | ||
versions: Record<string, string>; | ||
} | ||
|
||
const _process = (globalThis.process || | ||
Object.create(null)) as unknown as Process; | ||
|
||
const processShims = { | ||
const processShims: Partial<Process> = { | ||
versions: {}, | ||
}; | ||
|
||
export const process = new Proxy<Process>(_process, { | ||
get(target, prop) { | ||
get(target, prop: keyof Process) { | ||
if (prop === "env") { | ||
return env; | ||
} | ||
if (prop in target) { | ||
return target[prop]; | ||
} | ||
if (prop in processShims) { | ||
return processShims[prop as keyof typeof processShims]; | ||
return processShims[prop]; | ||
} | ||
}, | ||
}); |