diff options
author | Jed Fox <git@twopointzero.us> | 2019-10-02 11:55:28 -0400 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2019-10-02 11:55:28 -0400 |
commit | 99eec73b4b8813c6db7cae83f5415b031de0c2c7 (patch) | |
tree | 2a64e8dd3a7ae7fc097e14bba432d71193c39c6f /js/lib.deno_runtime.d.ts | |
parent | c920c5f62aba7eee0f6fa70f68f701e204ac1a9c (diff) |
feat: Add support for passing a key to Deno.env() (#2952)
This adds a new op to get a single env var.
Diffstat (limited to 'js/lib.deno_runtime.d.ts')
-rw-r--r-- | js/lib.deno_runtime.d.ts | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/js/lib.deno_runtime.d.ts b/js/lib.deno_runtime.d.ts index d0a720769..780503106 100644 --- a/js/lib.deno_runtime.d.ts +++ b/js/lib.deno_runtime.d.ts @@ -44,6 +44,16 @@ declare namespace Deno { export function env(): { [index: string]: string; }; + /** Returns the value of an environment variable at invocation. + * If the variable is not present, `undefined` will be returned. + * + * const myEnv = Deno.env(); + * console.log(myEnv.SHELL); + * myEnv.TEST_VAR = "HELLO"; + * const newEnv = Deno.env(); + * console.log(myEnv.TEST_VAR == newEnv.TEST_VAR); + */ + export function env(key: string): string | undefined; /** * Returns the current user's home directory. * Requires the `--allow-env` flag. |