diff options
author | Kitson Kelly <me@kitsonkelly.com> | 2019-02-13 02:08:56 +1100 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2019-02-12 10:08:56 -0500 |
commit | a21a5ad2fa4dcbad58fe63c298c69f8607705bf4 (patch) | |
tree | 03e0092f46813ffdf84f53ab58f71b8a0276207e /js/process_test.ts | |
parent | 1e5e091cb074896c7550b1b6f802582f12629048 (diff) |
Add Deno global namespace (#1748)
Resolves #1705
This PR adds the Deno APIs as a global namespace named `Deno`. For backwards
compatibility, the ability to `import * from "deno"` is preserved. I have tried
to convert every test and internal code the references the module to use the
namespace instead, but because I didn't break compatibility I am not sure.
On the REPL, `deno` no longer exists, replaced only with `Deno` to align with
the regular runtime.
The runtime type library includes both the namespace and module. This means it
duplicates the whole type information. When we remove the functionality from the
runtime, it will be a one line change to the library generator to remove the
module definition from the type library.
I marked a `TODO` in a couple places where to remove the `"deno"` module, but
there are additional places I know I didn't mark.
Diffstat (limited to 'js/process_test.ts')
-rw-r--r-- | js/process_test.ts | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/js/process_test.ts b/js/process_test.ts index 0b803bb32..e629dbe3d 100644 --- a/js/process_test.ts +++ b/js/process_test.ts @@ -1,15 +1,14 @@ // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. import { test, testPerm, assert, assertEqual } from "./test_util.ts"; -import { run, DenoError, ErrorKind } from "deno"; -import * as deno from "deno"; +const { run, DenoError, ErrorKind } = Deno; test(function runPermissions() { let caughtError = false; try { - deno.run({ args: ["python", "-c", "print('hello world')"] }); + Deno.run({ args: ["python", "-c", "print('hello world')"] }); } catch (e) { caughtError = true; - assertEqual(e.kind, deno.ErrorKind.PermissionDenied); + assertEqual(e.kind, Deno.ErrorKind.PermissionDenied); assertEqual(e.name, "PermissionDenied"); } assert(caughtError); @@ -39,7 +38,7 @@ testPerm({ run: true }, async function runCommandFailedWithCode() { }); testPerm({ run: true }, async function runCommandFailedWithSignal() { - if (deno.platform.os === "win") { + if (Deno.platform.os === "win") { return; // No signals on windows. } const p = run({ @@ -66,7 +65,7 @@ testPerm({ run: true }, function runNotFound() { testPerm({ write: true, run: true }, async function runWithCwdIsAsync() { const enc = new TextEncoder(); - const cwd = deno.makeTempDirSync({ prefix: "deno_command_test" }); + const cwd = Deno.makeTempDirSync({ prefix: "deno_command_test" }); const exitCodeFile = "deno_was_here"; const pyProgramFile = "poll_exit.py"; @@ -86,7 +85,7 @@ while True: pass `; - deno.writeFileSync(`${cwd}/${pyProgramFile}.py`, enc.encode(pyProgram)); + Deno.writeFileSync(`${cwd}/${pyProgramFile}.py`, enc.encode(pyProgram)); const p = run({ cwd, args: ["python", `${pyProgramFile}.py`] @@ -95,7 +94,7 @@ while True: // Write the expected exit code *after* starting python. // This is how we verify that `run()` is actually asynchronous. const code = 84; - deno.writeFileSync(`${cwd}/${exitCodeFile}`, enc.encode(`${code}`)); + Deno.writeFileSync(`${cwd}/${exitCodeFile}`, enc.encode(`${code}`)); const status = await p.status(); assertEqual(status.success, false); |