Skip to content

Commit

Permalink
feat: upgrade to deno_std 0.213 internally (#210)
Browse files Browse the repository at this point in the history
  • Loading branch information
dsherret authored Jan 25, 2024
1 parent 107b696 commit 76b5042
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 39 deletions.
2 changes: 1 addition & 1 deletion mod.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
);
Expand Down
7 changes: 3 additions & 4 deletions src/deps.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@ export {
assertRejects,
assertStringIncludes,
assertThrows,
} from "https://deno.land/[email protected]/assert/mod.ts";
export { readerFromStreamReader } from "https://deno.land/[email protected]/streams/reader_from_stream_reader.ts";
export { writableStreamFromWriter } from "https://deno.land/[email protected]/streams/writable_stream_from_writer.ts";
export { serve } from "https://deno.land/[email protected]/http/server.ts";
} from "https://deno.land/[email protected]/assert/mod.ts";
export { readerFromStreamReader } from "https://deno.land/[email protected]/streams/reader_from_stream_reader.ts";
export { toWritableStream } from "https://deno.land/[email protected]/io/to_writable_stream.ts";

/**
* Creates a temporary directory, changes the cwd to this directory,
Expand Down
30 changes: 15 additions & 15 deletions src/deps.ts
Original file line number Diff line number Diff line change
@@ -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/[email protected]/src/index.ts";
export { RealEnvironment as DenoWhichRealEnvironment, which, whichSync } from "https://deno.land/x/[email protected]/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";
34 changes: 15 additions & 19 deletions src/request.test.ts
Original file line number Diff line number Diff line change
@@ -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<void>) {
const controller = new AbortController();
const signal = controller.signal;
return new Promise<void>((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);
Expand All @@ -25,20 +35,6 @@ function withServer(action: (serverUrl: URL) => Promise<void>) {
} 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();
}
},
});
});
}
Expand Down Expand Up @@ -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));
});
Expand Down

0 comments on commit 76b5042

Please sign in to comment.