diff options
author | Nayeem Rahman <nayeemrmn99@gmail.com> | 2020-06-12 20:23:38 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-12 15:23:38 -0400 |
commit | 1fff6f55c3ba98a10018c6d374795e612061e9b6 (patch) | |
tree | 12074b6d44736b11513d857e437f9e30a6bf65a4 /std/examples | |
parent | 26bf56afdaf16634ffbaa23684faf3a44cc10f62 (diff) |
refactor: Don't destructure the Deno namespace (#6268)
Diffstat (limited to 'std/examples')
-rw-r--r-- | std/examples/chat/server_test.ts | 6 | ||||
-rw-r--r-- | std/examples/flags.ts | 3 | ||||
-rw-r--r-- | std/examples/test.ts | 3 | ||||
-rw-r--r-- | std/examples/tests/xeval_test.ts | 15 | ||||
-rw-r--r-- | std/examples/xeval.ts | 12 |
5 files changed, 19 insertions, 20 deletions
diff --git a/std/examples/chat/server_test.ts b/std/examples/chat/server_test.ts index 8e04b71d8..872f4ee12 100644 --- a/std/examples/chat/server_test.ts +++ b/std/examples/chat/server_test.ts @@ -5,8 +5,6 @@ import { BufReader } from "../../io/bufio.ts"; import { connectWebSocket, WebSocket } from "../../ws/mod.ts"; import { delay } from "../../async/delay.ts"; -const { test } = Deno; - async function startServer(): Promise< Deno.Process<Deno.RunOptions & { stdout: "piped" }> > { @@ -36,7 +34,7 @@ async function startServer(): Promise< return server; } -test({ +Deno.test({ name: "[examples/chat] GET / should serve html", async fn() { const server = await startServer(); @@ -54,7 +52,7 @@ test({ }, }); -test({ +Deno.test({ name: "[examples/chat] GET /ws should upgrade conn to ws", async fn() { const server = await startServer(); diff --git a/std/examples/flags.ts b/std/examples/flags.ts index 4625b8c96..d7f0fc650 100644 --- a/std/examples/flags.ts +++ b/std/examples/flags.ts @@ -1,7 +1,6 @@ // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. -const { args } = Deno; import { parse } from "../flags/mod.ts"; if (import.meta.main) { - console.dir(parse(args)); + console.dir(parse(Deno.args)); } diff --git a/std/examples/test.ts b/std/examples/test.ts index acda9293d..20db3fb1d 100644 --- a/std/examples/test.ts +++ b/std/examples/test.ts @@ -1,5 +1,4 @@ // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. -const { run } = Deno; import { assertEquals } from "../testing/asserts.ts"; /** Example of how to do basic tests */ @@ -13,7 +12,7 @@ Deno.test("t2", function (): void { /** A more complicated test that runs a subprocess. */ Deno.test("catSmoke", async function (): Promise<void> { - const p = run({ + const p = Deno.run({ cmd: [ Deno.execPath(), "run", diff --git a/std/examples/tests/xeval_test.ts b/std/examples/tests/xeval_test.ts index f86e27866..9f7c5db9e 100644 --- a/std/examples/tests/xeval_test.ts +++ b/std/examples/tests/xeval_test.ts @@ -7,7 +7,6 @@ import { assertStringContains, assert, } from "../../testing/asserts.ts"; -const { execPath, run } = Deno; Deno.test("xevalSuccess", async function (): Promise<void> { const chunks: string[] = []; @@ -32,8 +31,14 @@ const xevalPath = "examples/xeval.ts"; Deno.test({ name: "xevalCliReplvar", fn: async function (): Promise<void> { - const p = run({ - cmd: [execPath(), "run", xevalPath, "--replvar=abc", "console.log(abc)"], + const p = Deno.run({ + cmd: [ + Deno.execPath(), + "run", + xevalPath, + "--replvar=abc", + "console.log(abc)", + ], stdin: "piped", stdout: "piped", stderr: "null", @@ -48,8 +53,8 @@ Deno.test({ }); Deno.test("xevalCliSyntaxError", async function (): Promise<void> { - const p = run({ - cmd: [execPath(), "run", xevalPath, "("], + const p = Deno.run({ + cmd: [Deno.execPath(), "run", xevalPath, "("], stdin: "null", stdout: "piped", stderr: "piped", diff --git a/std/examples/xeval.ts b/std/examples/xeval.ts index d688a6bf7..814d306cd 100644 --- a/std/examples/xeval.ts +++ b/std/examples/xeval.ts @@ -1,7 +1,5 @@ import { parse } from "../flags/mod.ts"; import { readStringDelim } from "../io/bufio.ts"; -const { args, exit, stdin } = Deno; -type Reader = Deno.Reader; /* eslint-disable-next-line max-len */ // See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/AsyncFunction. @@ -40,7 +38,7 @@ export interface XevalOptions { const DEFAULT_DELIMITER = "\n"; export async function xeval( - reader: Reader, + reader: Deno.Reader, xevalFunc: XevalFunc, { delimiter = DEFAULT_DELIMITER }: XevalOptions = {} ): Promise<void> { @@ -53,7 +51,7 @@ export async function xeval( } async function main(): Promise<void> { - const parsedArgs = parse(args, { + const parsedArgs = parse(Deno.args, { boolean: ["help"], string: ["delim", "replvar"], alias: { @@ -69,7 +67,7 @@ async function main(): Promise<void> { if (parsedArgs._.length != 1) { console.error(HELP_MSG); console.log(parsedArgs._); - exit(1); + Deno.exit(1); } if (parsedArgs.help) { return console.log(HELP_MSG); @@ -82,12 +80,12 @@ async function main(): Promise<void> { // new AsyncFunction()'s error message for this particular case isn't great. if (!replVar.match(/^[_$A-z][_$A-z0-9]*$/)) { console.error(`Bad replvar identifier: "${replVar}"`); - exit(1); + Deno.exit(1); } const xEvalFunc = new AsyncFunction(replVar, code); - await xeval(stdin, xEvalFunc, { delimiter }); + await xeval(Deno.stdin, xEvalFunc, { delimiter }); } if (import.meta.main) { |