feat: add plugin buildStart and buildEnd hooks (#1770)

This commit is contained in:
Marvin Hagemeister
2023-09-18 17:46:34 +02:00
committed by GitHub
parent d94d3db4aa
commit c76f15479f
11 changed files with 161 additions and 15 deletions
+17 -1
View File
@@ -8,7 +8,7 @@ import {
} from "./deps.ts";
import manifest from "./fixture_plugin/fresh.gen.ts";
import options from "./fixture_plugin/options.ts";
import { startFreshServer } from "./test_utils.ts";
import { runBuild, startFreshServer } from "./test_utils.ts";
const ctx = await ServerContext.fromManifest(manifest, options);
const handler = ctx.handler();
@@ -129,3 +129,19 @@ Deno.test({
for await (const _ of lines) { /* noop */ }
},
});
Deno.test("calls buildStart() and buildEnd()", async () => {
const result = await runBuild("./tests/fixture_plugin_lifecycle/dev.ts");
let out = result.stdout.split("\n");
const idx = out.findIndex((line) => line.startsWith("Plugin"));
const idxEnd = out.findLastIndex((line) => line.startsWith("Plugin"));
out = out.slice(idx, idxEnd + 1);
assertEquals(out, [
"Plugin a: buildStart",
"Plugin b: buildStart",
"Plugin a: buildEnd",
"Plugin b: buildEnd",
]);
});