From 502a56c47b491355bdc0bd3afe12b28cdd510503 Mon Sep 17 00:00:00 2001 From: Valentin Anger Date: Wed, 29 Apr 2020 20:48:19 +0200 Subject: [PATCH] BREAKING: Map-like interface for Deno.env (denoland/deno#4942) --- examples/gist.ts | 2 +- node/module.ts | 4 ++-- node/process.ts | 2 +- node/process_test.ts | 2 +- path/win32.ts | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/examples/gist.ts b/examples/gist.ts index c41b9b98ed596..fbe4384e1a531 100755 --- a/examples/gist.ts +++ b/examples/gist.ts @@ -7,7 +7,7 @@ function pathBase(p: string): string { return parts[parts.length - 1]; } -const token = Deno.env()["GIST_TOKEN"]; +const token = Deno.env.get("GIST_TOKEN"); if (!token) { console.error("GIST_TOKEN environmental variable not set."); console.error("Get a token here: https://github.com/settings/tokens"); diff --git a/node/module.ts b/node/module.ts index b7a0107d021b3..9203764f050d4 100644 --- a/node/module.ts +++ b/node/module.ts @@ -534,8 +534,8 @@ class Module { } static _initPaths(): void { - const homeDir = Deno.env("HOME"); - const nodePath = Deno.env("NODE_PATH"); + const homeDir = Deno.env.get("HOME"); + const nodePath = Deno.env.get("NODE_PATH"); // Removed $PREFIX/bin/node case diff --git a/node/process.ts b/node/process.ts index 310a7e8140426..f90e1eada80c2 100644 --- a/node/process.ts +++ b/node/process.ts @@ -30,7 +30,7 @@ export const process = { on, get env(): { [index: string]: string } { // using getter to avoid --allow-env unless it's used - return Deno.env(); + return Deno.env.toObject(); }, get argv(): string[] { // Deno.execPath() also requires --allow-env diff --git a/node/process_test.ts b/node/process_test.ts index b9d5388eace1d..3afaa4cdfbe27 100644 --- a/node/process_test.ts +++ b/node/process_test.ts @@ -3,7 +3,7 @@ import { assert, assertThrows, assertEquals } from "../testing/asserts.ts"; import { process } from "./process.ts"; // NOTE: Deno.execPath() (and thus process.argv) currently requires --allow-env -// (Also Deno.env() (and process.env) requires --allow-env but it's more obvious) +// (Also Deno.env.toObject() (and process.env) requires --allow-env but it's more obvious) test({ name: "process.cwd and process.chdir success", diff --git a/path/win32.ts b/path/win32.ts index d4febf706a2f3..9bba66e2bfbca 100644 --- a/path/win32.ts +++ b/path/win32.ts @@ -39,7 +39,7 @@ export function resolve(...pathSegments: string[]): string { // absolute path, get cwd for that drive, or the process cwd if // the drive cwd is not available. We're sure the device is not // a UNC path at this points, because UNC paths are always absolute. - path = env()[`=${resolvedDevice}`] || cwd(); + path = env.get(`=${resolvedDevice}`) || cwd(); // Verify that a cwd was found and that it actually points // to our drive. If not, default to the drive's root.