From 99eec73b4b8813c6db7cae83f5415b031de0c2c7 Mon Sep 17 00:00:00 2001 From: Jed Fox Date: Wed, 2 Oct 2019 11:55:28 -0400 Subject: feat: Add support for passing a key to Deno.env() (#2952) This adds a new op to get a single env var. --- js/lib.deno_runtime.d.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'js/lib.deno_runtime.d.ts') 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. -- cgit v1.2.3