mirror of
https://github.com/denoland/deno.git
synced 2025-09-27 20:59:10 +00:00
feat: Add support for passing a key to Deno.env() (#2952)
This adds a new op to get a single env var.
This commit is contained in:
parent
c920c5f62a
commit
99eec73b4b
7 changed files with 144 additions and 9 deletions
10
js/lib.deno_runtime.d.ts
vendored
10
js/lib.deno_runtime.d.ts
vendored
|
@ -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.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue