diff options
author | Valentin Anger <syrupthinker@gryphno.de> | 2020-04-29 20:48:19 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-29 14:48:19 -0400 |
commit | 721a4ad59d4a8bdd8470d6b98839137f14c84ba9 (patch) | |
tree | a8a7f7810a92c366224564b62b5fe7acab717466 /cli/js/ops/os.ts | |
parent | 17cf2ecdacea2254c06374866c4e7e83e282226d (diff) |
BREAKING: Map-like interface for Deno.env (#4942)
Diffstat (limited to 'cli/js/ops/os.ts')
-rw-r--r-- | cli/js/ops/os.ts | 23 |
1 files changed, 7 insertions, 16 deletions
diff --git a/cli/js/ops/os.ts b/cli/js/ops/os.ts index e01718c8c..30aa6d0d4 100644 --- a/cli/js/ops/os.ts +++ b/cli/js/ops/os.ts @@ -27,22 +27,13 @@ function getEnv(key: string): string | undefined { return sendSync("op_get_env", { key })[0]; } -export function env(): { [index: string]: string }; -export function env(key: string): string | undefined; -export function env( - key?: string -): { [index: string]: string } | string | undefined { - if (key) { - return getEnv(key); - } - const env = sendSync("op_env"); - return new Proxy(env, { - set(obj, prop: string, value: string): boolean { - setEnv(prop, value); - return Reflect.set(obj, prop, value); - }, - }); -} +export const env = { + get: getEnv, + toObject(): { [key: string]: string } { + return sendSync("op_env"); + }, + set: setEnv, +}; type DirKind = | "home" |