From 764e76b66aaffa389e34b78ff2b6110f6de17832 Mon Sep 17 00:00:00 2001 From: Max Duval Date: Tue, 12 Mar 2024 16:40:52 +0000 Subject: [PATCH] test: improve shutting down --- deno.jsonc | 2 +- src/build.test.ts | 2 +- src/build.ts | 7 ++++++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/deno.jsonc b/deno.jsonc index 5af1411..df3ba45 100644 --- a/deno.jsonc +++ b/deno.jsonc @@ -1,7 +1,7 @@ { "tasks": { "build": "deno run -A src/build.ts --site_dir src/_site", - "dev": "deno run -A --node-modules-dir src/build.ts --site_dir src/_site --watch --base=mononykus" + "dev": "deno run -A src/build.ts --site_dir src/_site --watch --base=mononykus" }, "compilerOptions": { "strict": true, diff --git a/src/build.test.ts b/src/build.test.ts index b685bbe..51c779b 100644 --- a/src/build.test.ts +++ b/src/build.test.ts @@ -46,7 +46,7 @@ Deno.test({ const html = await response.text(); - process.kill(); + process.kill("SIGINT"); await process.output(); assert(html.startsWith( diff --git a/src/build.ts b/src/build.ts index d36f3b0..30871c0 100644 --- a/src/build.ts +++ b/src/build.ts @@ -137,7 +137,7 @@ export const build = async ( await rebuild({ base, out_dir, site_dir, minify }); - esbuild.stop(); + await esbuild.stop(); }; export const watch = async ( @@ -173,6 +173,11 @@ export const watch = async ( if (import.meta.main) { if (flags.watch) { + Deno.addSignalListener("SIGINT", async () => { + console.log("\nShutting down gracefully…") + await esbuild.stop(); + }); + await watch(options); } else { await build(options);