summaryrefslogtreecommitdiff
path: root/packages/integrations/deno/test/helpers.js
blob: 3a3fb0c17eab2f9e2ff3bc9ef9db25dea9d478bb (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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/server/entry.mjs', url));
	if (!mod.running()) {
		mod.start();
	}
	await cb();
	await mod.stop();
	await close();
}