Skip to content

Commit e5ab9fd

Browse files
committed
deno now has AsyncDisposableStack
1 parent 763fbbc commit e5ab9fd

File tree

3 files changed

+10
-41
lines changed

3 files changed

+10
-41
lines changed

build/dev.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import { assert } from "@std/assert/assert";
44
import { exists } from "@std/fs/exists";
55
import { BuildOptions, context } from "esbuild";
6-
import { AsyncDisposableStack } from "../misc/async_disposable_stack.ts";
76
import { OPTIONS } from "./config.ts";
87

98
const DICTIONARY = new URL("../dictionary/dictionary.ts", import.meta.url);
@@ -15,11 +14,16 @@ const BUILD_OPTIONS: BuildOptions = {
1514
};
1615
async function watchMain(): Promise<AsyncDisposable> {
1716
await using stack = new AsyncDisposableStack();
18-
const buildContext = await context(BUILD_OPTIONS);
19-
stack.defer(async () => await buildContext.dispose());
20-
buildContext.watch();
21-
buildContext.serve({ servedir: "./dist/" });
22-
return stack.move();
17+
const buildContext = stack.use({
18+
context: await context(BUILD_OPTIONS),
19+
async [Symbol.asyncDispose](): Promise<void> {
20+
await this.context.dispose();
21+
},
22+
});
23+
buildContext.context.watch();
24+
buildContext.context.serve({ servedir: "./dist/" });
25+
stack.move();
26+
return buildContext;
2327
}
2428
async function watchDictionary(): Promise<number> {
2529
const command = new Deno.Command(Deno.execPath(), {

dictionary/watch.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import { unreachable } from "@std/assert/unreachable";
44
import { debounce } from "@std/async/debounce";
5-
import { AsyncDisposableStack } from "../misc/async_disposable_stack.ts";
65
import { build } from "./build.ts";
76

87
if (import.meta.main) {

misc/async_disposable_stack.ts

Lines changed: 0 additions & 34 deletions
This file was deleted.

0 commit comments

Comments
 (0)