diff --git a/mod.test.ts b/mod.test.ts index 4606efc..e71bfad 100644 --- a/mod.test.ts +++ b/mod.test.ts @@ -1013,7 +1013,7 @@ Deno.test("shebang support", async (t) => { step("without -S, but valid", async () => { dir.join("echo_stdin.ts").writeTextSync( [ - "#!/usr/bin/env -S deno run --unstable --allow-run", + "#!/usr/bin/env -S deno run --allow-run", "await new Deno.Command('deno', { args: ['run', ...Deno.args] }).spawn();", ].join("\n"), ); diff --git a/src/deps.test.ts b/src/deps.test.ts index c9d445d..1705d22 100644 --- a/src/deps.test.ts +++ b/src/deps.test.ts @@ -7,10 +7,9 @@ export { assertRejects, assertStringIncludes, assertThrows, -} from "https://deno.land/std@0.209.0/assert/mod.ts"; -export { readerFromStreamReader } from "https://deno.land/std@0.209.0/streams/reader_from_stream_reader.ts"; -export { writableStreamFromWriter } from "https://deno.land/std@0.209.0/streams/writable_stream_from_writer.ts"; -export { serve } from "https://deno.land/std@0.209.0/http/server.ts"; +} from "https://deno.land/std@0.213.0/assert/mod.ts"; +export { readerFromStreamReader } from "https://deno.land/std@0.213.0/streams/reader_from_stream_reader.ts"; +export { toWritableStream } from "https://deno.land/std@0.213.0/io/to_writable_stream.ts"; /** * Creates a temporary directory, changes the cwd to this directory, diff --git a/src/deps.ts b/src/deps.ts index 280ecbc..b303264 100644 --- a/src/deps.ts +++ b/src/deps.ts @@ -1,18 +1,18 @@ -export * as colors from "https://deno.land/std@0.209.0/fmt/colors.ts"; -export * as fs from "https://deno.land/std@0.209.0/fs/mod.ts"; -export { Buffer } from "https://deno.land/std@0.209.0/io/buffer.ts"; -export { BufReader } from "https://deno.land/std@0.209.0/io/buf_reader.ts"; -export * as path from "https://deno.land/std@0.209.0/path/mod.ts"; -export { readAll } from "https://deno.land/std@0.209.0/streams/read_all.ts"; -export { readerFromStreamReader } from "https://deno.land/std@0.209.0/streams/reader_from_stream_reader.ts"; -export { writeAll, writeAllSync } from "https://deno.land/std@0.209.0/streams/write_all.ts"; +export * as colors from "https://deno.land/std@0.213.0/fmt/colors.ts"; +export * as fs from "https://deno.land/std@0.213.0/fs/mod.ts"; +export { Buffer } from "https://deno.land/std@0.213.0/io/buffer.ts"; +export { BufReader } from "https://deno.land/std@0.213.0/io/buf_reader.ts"; +export * as path from "https://deno.land/std@0.213.0/path/mod.ts"; +export { readAll } from "https://deno.land/std@0.213.0/streams/read_all.ts"; +export { readerFromStreamReader } from "https://deno.land/std@0.213.0/streams/reader_from_stream_reader.ts"; +export { writeAll, writeAllSync } from "https://deno.land/std@0.213.0/io/write_all.ts"; export { outdent } from "https://deno.land/x/outdent@v0.8.0/src/index.ts"; export { RealEnvironment as DenoWhichRealEnvironment, which, whichSync } from "https://deno.land/x/which@0.3.0/mod.ts"; -export { emptyDir, emptyDirSync } from "https://deno.land/std@0.209.0/fs/empty_dir.ts"; -export { ensureDir, ensureDirSync } from "https://deno.land/std@0.209.0/fs/ensure_dir.ts"; -export { ensureFile, ensureFileSync } from "https://deno.land/std@0.209.0/fs/ensure_file.ts"; -export { expandGlob, type ExpandGlobOptions, expandGlobSync } from "https://deno.land/std@0.209.0/fs/expand_glob.ts"; -export { move, moveSync } from "https://deno.land/std@0.209.0/fs/move.ts"; -export { copy, copySync } from "https://deno.land/std@0.209.0/fs/copy.ts"; -export { walk, type WalkEntry, WalkError, type WalkOptions, walkSync } from "https://deno.land/std@0.209.0/fs/walk.ts"; +export { emptyDir, emptyDirSync } from "https://deno.land/std@0.213.0/fs/empty_dir.ts"; +export { ensureDir, ensureDirSync } from "https://deno.land/std@0.213.0/fs/ensure_dir.ts"; +export { ensureFile, ensureFileSync } from "https://deno.land/std@0.213.0/fs/ensure_file.ts"; +export { expandGlob, type ExpandGlobOptions, expandGlobSync } from "https://deno.land/std@0.213.0/fs/expand_glob.ts"; +export { move, moveSync } from "https://deno.land/std@0.213.0/fs/move.ts"; +export { copy, copySync } from "https://deno.land/std@0.213.0/fs/copy.ts"; +export { walk, type WalkEntry, WalkError, type WalkOptions, walkSync } from "https://deno.land/std@0.213.0/fs/walk.ts"; diff --git a/src/request.test.ts b/src/request.test.ts index f1de046..742902b 100644 --- a/src/request.test.ts +++ b/src/request.test.ts @@ -1,12 +1,22 @@ import { Buffer, path } from "./deps.ts"; -import { assertEquals, assertRejects, serve, writableStreamFromWriter } from "./deps.test.ts"; +import { assertEquals, assertRejects, toWritableStream } from "./deps.test.ts"; import { RequestBuilder } from "./request.ts"; function withServer(action: (serverUrl: URL) => Promise) { - const controller = new AbortController(); - const signal = controller.signal; return new Promise((resolve, reject) => { - serve((request) => { + const server = Deno.serve({ + hostname: "localhost", + async onListen(details) { + const url = new URL(`http://${details.hostname}:${details.port}/`); + try { + await action(url); + resolve(); + } catch (err) { + reject(err); + } + await server.shutdown(); + }, + }, (request) => { const url = new URL(request.url); if (url.pathname === "/text-file") { const data = "text".repeat(1000); @@ -25,20 +35,6 @@ function withServer(action: (serverUrl: URL) => Promise) { } else { return new Response("Not Found", { status: 404 }); } - }, { - hostname: "localhost", - signal, - async onListen(details) { - const url = new URL(`http://${details.hostname}:${details.port}/`); - try { - await action(url); - resolve(); - controller.abort(); - } catch (err) { - reject(err); - controller.abort(); - } - }, }); }); } @@ -92,7 +88,7 @@ Deno.test("$.request", (t) => { await new RequestBuilder() .url(new URL("/text-file", serverUrl)) .showProgress() - .pipeTo(writableStreamFromWriter(buffer)); + .pipeTo(toWritableStream(buffer)); const text = new TextDecoder().decode(buffer.bytes()); assertEquals(text, "text".repeat(1000)); });