astro/packages/integrations/deno/test/helpers.js
Matthew Phillips 13b271bc7d
Deno adapter (#2934)
* Bundle everything, commit 1

* Get everything working

* Remove dependency on readable-stream

* Adds a changeset

* Fix ts errors

* Use the node logger in tests

* Callback the logger when done writing

* Fix test helper to await the callback

* Use serialize-javascript again

* Remove dead code

* Rename hook

* Oops
2022-03-30 08:42:19 -04:00

20 lines
598 B
JavaScript

import { fromFileUrl } from './deps.js';
const dir = new URL('./', import.meta.url);
export async function runBuild(fixturePath) {
let proc = Deno.run({
cmd: ['node', '../../../../../astro/astro.js', 'build', '--silent'],
cwd: fromFileUrl(new URL(fixturePath, dir))
});
await proc.status();
return async () => await proc.close();
}
export async function runBuildAndStartApp(fixturePath, cb) {
const url = new URL(fixturePath, dir);
const close = await runBuild(fixturePath);
const mod = await import(new URL('./dist/entry.mjs', url));
await cb();
await mod.stop();
await close();
}