From 2ba7de2d04fb7fb5847b86d9c549f1cbf9c68d5a Mon Sep 17 00:00:00 2001 From: Bert Belder Date: Mon, 25 Feb 2019 21:35:50 -0800 Subject: [PATCH] Change `import { x } from "deno"` to `const { x } = Deno` (denoland/deno_std#218) Original: https://github.com/denoland/deno_std/commit/6063378a9284a48d42e37b4899f947c5c8bbf0b3 --- benching/mod.ts | 2 +- colors/mod.ts | 2 +- examples/echo_server.ts | 2 +- examples/gist.ts | 2 +- examples/test.ts | 2 +- flags/README.md | 2 +- flags/example.ts | 2 +- format.ts | 2 +- fs/path/constants.ts | 2 +- fs/path/mod.ts | 2 +- fs/path/resolve_test.ts | 2 +- fs/path/zero_length_strings_test.ts | 2 +- fs/walk.ts | 13 ++----------- fs/walk_test.ts | 7 +++---- http/file_server.ts | 3 ++- http/file_server_test.ts | 2 +- http/server.ts | 3 ++- http/server_test.ts | 2 +- io/bufio_test.ts | 3 ++- io/ioutil_test.ts | 3 ++- io/readers_test.ts | 2 +- io/util.ts | 3 ++- io/util_test.ts | 2 +- io/writers_test.ts | 2 +- log/handlers.ts | 3 ++- multipart/multipart.ts | 4 ++-- multipart/multipart_test.ts | 2 +- prettier/main.ts | 11 +---------- prettier/main_test.ts | 2 +- prettier/util.ts | 2 +- ws/mod.ts | 3 ++- ws/test.ts | 2 +- 32 files changed, 43 insertions(+), 55 deletions(-) diff --git a/benching/mod.ts b/benching/mod.ts index be77b52c..61df5c06 100644 --- a/benching/mod.ts +++ b/benching/mod.ts @@ -1,6 +1,6 @@ // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. -import { exit, noColor } from "deno"; +const { exit, noColor } = Deno; interface BenchmarkClock { start: number; diff --git a/colors/mod.ts b/colors/mod.ts index c8bb5b53..7a45905c 100644 --- a/colors/mod.ts +++ b/colors/mod.ts @@ -1,5 +1,5 @@ // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. -import { noColor } from "deno"; +const { noColor } = Deno; interface Code { open: string; diff --git a/examples/echo_server.ts b/examples/echo_server.ts index 5776e77e..95b9f741 100644 --- a/examples/echo_server.ts +++ b/examples/echo_server.ts @@ -1,5 +1,5 @@ // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. -import { listen, copy } from "deno"; +const { listen, copy } = Deno; (async () => { const addr = "0.0.0.0:8080"; diff --git a/examples/gist.ts b/examples/gist.ts index 860678d8..8ce68a94 100755 --- a/examples/gist.ts +++ b/examples/gist.ts @@ -1,7 +1,7 @@ #!/usr/bin/env deno --allow-net --allow-env // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. -import { args, env, exit, readFile } from "deno"; +const { args, env, exit, readFile } = Deno; import { parse } from "https://deno.land/x/flags/mod.ts"; function pathBase(p: string): string { diff --git a/examples/test.ts b/examples/test.ts index 65ff7efa..30fdcfc4 100644 --- a/examples/test.ts +++ b/examples/test.ts @@ -1,5 +1,5 @@ // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. -import { run } from "deno"; +const { run } = Deno; import { test, assertEqual } from "../testing/mod.ts"; /** Example of how to do basic tests */ diff --git a/flags/README.md b/flags/README.md index 7b63006d..b002bf56 100644 --- a/flags/README.md +++ b/flags/README.md @@ -5,7 +5,7 @@ Command line arguments parser for Deno based on minimist # Example ```ts -import { args } from "deno"; +const { args } = Deno; import { parse } from "https://deno.land/x/flags/mod.ts"; console.dir(parse(args)); diff --git a/flags/example.ts b/flags/example.ts index 54d64b68..04ace467 100644 --- a/flags/example.ts +++ b/flags/example.ts @@ -1,5 +1,5 @@ // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. -import { args } from "deno"; +const { args } = Deno; import { parse } from "./mod.ts"; console.dir(parse(args)); diff --git a/format.ts b/format.ts index 4de5cfa8..fa538d53 100755 --- a/format.ts +++ b/format.ts @@ -1,6 +1,6 @@ #!/usr/bin/env deno --allow-run --allow-write --allow-read // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. -import { exit, args } from "deno"; +const { exit, args } = Deno; import { parse } from "./flags/mod.ts"; import { xrun, executableSuffix } from "./prettier/util.ts"; diff --git a/fs/path/constants.ts b/fs/path/constants.ts index ce121f9a..cfba4ebd 100644 --- a/fs/path/constants.ts +++ b/fs/path/constants.ts @@ -1,7 +1,7 @@ // Copyright the Browserify authors. MIT License. // Ported from https://github.com/browserify/path-browserify/ -import { platform } from "deno"; +const { platform } = Deno; // Alphabet chars. export const CHAR_UPPERCASE_A = 65; /* A */ diff --git a/fs/path/mod.ts b/fs/path/mod.ts index 7adb230d..4ca630ed 100644 --- a/fs/path/mod.ts +++ b/fs/path/mod.ts @@ -1,7 +1,7 @@ // Copyright the Browserify authors. MIT License. // Ported from https://github.com/browserify/path-browserify/ -import { cwd, env } from "deno"; +const { cwd, env } = Deno; import { FormatInputPathObject, ParsedPath } from "./interface.ts"; import { isWindows, diff --git a/fs/path/resolve_test.ts b/fs/path/resolve_test.ts index 7c2b5524..2259dd02 100644 --- a/fs/path/resolve_test.ts +++ b/fs/path/resolve_test.ts @@ -1,9 +1,9 @@ // Copyright the Browserify authors. MIT License. // Ported from https://github.com/browserify/path-browserify/ +const { cwd } = Deno; import { test, assertEqual } from "../../testing/mod.ts"; import * as path from "./mod.ts"; -import { cwd } from "deno"; const windowsTests = // arguments result diff --git a/fs/path/zero_length_strings_test.ts b/fs/path/zero_length_strings_test.ts index d069c781..c769c9a7 100644 --- a/fs/path/zero_length_strings_test.ts +++ b/fs/path/zero_length_strings_test.ts @@ -1,9 +1,9 @@ // Copyright the Browserify authors. MIT License. // Ported from https://github.com/browserify/path-browserify/ +const { cwd } = Deno; import { test, assertEqual } from "../../testing/mod.ts"; import * as path from "./mod.ts"; -import { cwd } from "deno"; const pwd = cwd(); diff --git a/fs/walk.ts b/fs/walk.ts index 92e4ba59..10393ae0 100644 --- a/fs/walk.ts +++ b/fs/walk.ts @@ -1,14 +1,5 @@ -import { - FileInfo, - cwd, - readDir, - readDirSync, - readlink, - readlinkSync, - stat, - statSync -} from "deno"; -import { relative } from "path.ts"; +const { readDir, readDirSync, readlink, readlinkSync, stat, statSync } = Deno; +import { FileInfo } from "deno"; export interface WalkOptions { maxDepth?: number; diff --git a/fs/walk_test.ts b/fs/walk_test.ts index 7f21a2fb..d5427399 100644 --- a/fs/walk_test.ts +++ b/fs/walk_test.ts @@ -1,15 +1,14 @@ -import { +const { cwd, chdir, - FileInfo, makeTempDir, mkdir, open, platform, remove, symlink -} from "deno"; - +} = Deno; +import { FileInfo } from "deno"; import { walk, walkSync, WalkOptions } from "./walk.ts"; import { test, assert, TestFunction } from "../testing/mod.ts"; diff --git a/http/file_server.ts b/http/file_server.ts index 1f3fdd58..20ad45be 100755 --- a/http/file_server.ts +++ b/http/file_server.ts @@ -6,13 +6,14 @@ // TODO Add tests like these: // https://github.com/indexzero/http-server/blob/master/test/http-server-test.js +const { ErrorKind, cwd, args, stat, readDir, open } = Deno; +import { DenoError } from "deno"; import { listenAndServe, ServerRequest, setContentLength, Response } from "./server.ts"; -import { cwd, DenoError, ErrorKind, args, stat, readDir, open } from "deno"; import { extname } from "../fs/path.ts"; import { contentType } from "../media_types/mod.ts"; diff --git a/http/file_server_test.ts b/http/file_server_test.ts index 698857dc..cf4b8dcb 100644 --- a/http/file_server_test.ts +++ b/http/file_server_test.ts @@ -1,5 +1,5 @@ // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. -import { readFile, run } from "deno"; +const { readFile, run } = Deno; import { test, assert, assertEqual } from "../testing/mod.ts"; import { BufReader } from "../io/bufio.ts"; diff --git a/http/server.ts b/http/server.ts index 400171fc..c6cd95f8 100644 --- a/http/server.ts +++ b/http/server.ts @@ -1,5 +1,6 @@ // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. -import { listen, Conn, toAsyncIterator, Reader, Writer, copy } from "deno"; +const { listen, toAsyncIterator, copy } = Deno; +import { Conn, Reader, Writer } from "deno"; import { BufReader, BufState, BufWriter } from "../io/bufio.ts"; import { TextProtoReader } from "../textproto/mod.ts"; import { STATUS_TEXT } from "./http_status.ts"; diff --git a/http/server_test.ts b/http/server_test.ts index 099547d0..cc5863eb 100644 --- a/http/server_test.ts +++ b/http/server_test.ts @@ -5,7 +5,7 @@ // Ported from // https://github.com/golang/go/blob/master/src/net/http/responsewrite_test.go -import { Buffer } from "deno"; +const { Buffer } = Deno; import { assertEqual, test } from "../testing/mod.ts"; import { Response, ServerRequest } from "./server.ts"; import { BufReader, BufWriter } from "../io/bufio.ts"; diff --git a/io/bufio_test.ts b/io/bufio_test.ts index e63f1c5c..0a261dae 100644 --- a/io/bufio_test.ts +++ b/io/bufio_test.ts @@ -3,7 +3,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -import { Buffer, Reader, ReadResult } from "deno"; +const { Buffer } = Deno; +import { Reader, ReadResult } from "deno"; import { test, assert, assertEqual } from "../testing/mod.ts"; import { BufReader, BufState, BufWriter } from "./bufio.ts"; import * as iotest from "./iotest.ts"; diff --git a/io/ioutil_test.ts b/io/ioutil_test.ts index 2c78b256..168aad52 100644 --- a/io/ioutil_test.ts +++ b/io/ioutil_test.ts @@ -1,5 +1,6 @@ // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. -import { Buffer, Reader, ReadResult } from "deno"; +const { Buffer } = Deno; +import { Reader, ReadResult } from "deno"; import { assert, assertEqual, runTests, test } from "../testing/mod.ts"; import { copyN, diff --git a/io/readers_test.ts b/io/readers_test.ts index 0bc8ca36..8da9d6e7 100644 --- a/io/readers_test.ts +++ b/io/readers_test.ts @@ -1,7 +1,7 @@ +const { copy } = Deno; import { assert, test } from "../testing/mod.ts"; import { MultiReader, StringReader } from "./readers.ts"; import { StringWriter } from "./writers.ts"; -import { copy } from "deno"; import { copyN } from "./ioutil.ts"; import { decode } from "../strings/strings.ts"; diff --git a/io/util.ts b/io/util.ts index 954808c6..d87776ee 100644 --- a/io/util.ts +++ b/io/util.ts @@ -1,5 +1,6 @@ // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. -import { Buffer, File, mkdir, open, Reader } from "deno"; +const { Buffer, mkdir, open } = Deno; +import { File, Reader } from "deno"; import { encode } from "../strings/strings.ts"; import * as path from "../fs/path.ts"; // `off` is the offset into `dst` where it will at which to begin writing values diff --git a/io/util_test.ts b/io/util_test.ts index c3f13461..62cdfe53 100644 --- a/io/util_test.ts +++ b/io/util_test.ts @@ -1,7 +1,7 @@ // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. +const { remove } = Deno; import { test, assert } from "../testing/mod.ts"; import { copyBytes, tempFile } from "./util.ts"; -import { remove } from "deno"; import * as path from "../fs/path.ts"; test(function testCopyBytes() { diff --git a/io/writers_test.ts b/io/writers_test.ts index 01388497..94c58417 100644 --- a/io/writers_test.ts +++ b/io/writers_test.ts @@ -1,8 +1,8 @@ +const { copy } = Deno; import { assert, test } from "../testing/mod.ts"; import { StringWriter } from "./writers.ts"; import { StringReader } from "./readers.ts"; import { copyN } from "./ioutil.ts"; -import { copy } from "deno"; test(async function ioStringWriter() { const w = new StringWriter("base"); diff --git a/log/handlers.ts b/log/handlers.ts index 5c65c4fd..96d8c056 100644 --- a/log/handlers.ts +++ b/log/handlers.ts @@ -1,5 +1,6 @@ // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. -import { open, File, Writer } from "deno"; +const { open } = Deno; +import { File, Writer } from "deno"; import { getLevelByName, LogLevel } from "./levels.ts"; import { LogRecord } from "./logger.ts"; import { red, yellow, blue, bold } from "../colors/mod.ts"; diff --git a/multipart/multipart.ts b/multipart/multipart.ts index f0caa216..70874ed8 100644 --- a/multipart/multipart.ts +++ b/multipart/multipart.ts @@ -1,7 +1,7 @@ // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. -import { Buffer, Closer, copy, Reader, ReadResult, remove, Writer } from "deno"; - +const { Buffer, copy, remove } = Deno; +import { Closer, Reader, ReadResult, Writer } from "deno"; import { FormFile } from "./formfile.ts"; import { bytesFindIndex, diff --git a/multipart/multipart_test.ts b/multipart/multipart_test.ts index 3181e45c..a87db60d 100644 --- a/multipart/multipart_test.ts +++ b/multipart/multipart_test.ts @@ -1,5 +1,6 @@ // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. +const { Buffer, copy, open, remove } = Deno; import { assert, test } from "../testing/mod.ts"; import { matchAfterPrefix, @@ -7,7 +8,6 @@ import { MultipartWriter, scanUntilBoundary } from "./multipart.ts"; -import { Buffer, copy, open, remove } from "deno"; import * as path from "../fs/path.ts"; import { FormFile, isFormFile } from "./formfile.ts"; import { StringWriter } from "../io/writers.ts"; diff --git a/prettier/main.ts b/prettier/main.ts index 435206dc..70c22508 100755 --- a/prettier/main.ts +++ b/prettier/main.ts @@ -2,16 +2,7 @@ // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. // This script formats the given source files. If the files are omitted, it // formats the all files in the repository. -import { - args, - platform, - readAll, - lstat, - exit, - run, - readFile, - writeFile -} from "deno"; +const { args, platform, readAll, lstat, exit, run, readFile, writeFile } = Deno; import { xrun } from "./util.ts"; import { parse } from "../flags/mod.ts"; import { prettier, prettierPlugins } from "./prettier.ts"; diff --git a/prettier/main_test.ts b/prettier/main_test.ts index d770d723..165081e0 100644 --- a/prettier/main_test.ts +++ b/prettier/main_test.ts @@ -1,7 +1,7 @@ // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. import { test, assertEqual } from "../testing/mod.ts"; import { xrun, executableSuffix } from "./util.ts"; -import { readAll } from "deno"; +const { readAll } = Deno; const decoder = new TextDecoder(); diff --git a/prettier/util.ts b/prettier/util.ts index 179be444..0be583f7 100644 --- a/prettier/util.ts +++ b/prettier/util.ts @@ -1,5 +1,5 @@ // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. -import { platform, run } from "deno"; +const { platform, run } = Deno; // Runs a command in cross-platform way export function xrun(opts) { diff --git a/ws/mod.ts b/ws/mod.ts index 6433a75d..bb943c71 100644 --- a/ws/mod.ts +++ b/ws/mod.ts @@ -1,5 +1,6 @@ // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. -import { Buffer, Writer, Conn } from "deno"; +const { Buffer } = Deno; +import { Writer, Conn } from "deno"; import { BufReader, BufWriter } from "../io/bufio.ts"; import { readLong, readShort, sliceLongToBytes } from "../io/ioutil.ts"; import { Sha1 } from "./sha1.ts"; diff --git a/ws/test.ts b/ws/test.ts index 684c4300..46ea1cb8 100644 --- a/ws/test.ts +++ b/ws/test.ts @@ -1,7 +1,7 @@ // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. import "./sha1_test.ts"; -import { Buffer } from "deno"; +const { Buffer } = Deno; import { BufReader } from "../io/bufio.ts"; import { assert, assertEqual, test } from "../testing/mod.ts"; import { -- GitLab