test: refactor template

This commit is contained in:
cha0s 2024-02-14 22:35:51 -06:00
parent 3b05e4004b
commit 1550aca267
2 changed files with 5 additions and 4 deletions

View File

@ -1,5 +1,5 @@
import {cp} from 'fs/promises';
import {join} from 'path';
import {join, resolve} from 'path';
import {createWorkspace} from '@flecks/core/build/testing';
@ -7,10 +7,10 @@ const {
FLECKS_CORE_ROOT = process.cwd(),
} = process.env;
export const templateDefaultPath = join(FLECKS_CORE_ROOT, 'test', 'template');
export const templateDefaultPath = 'template';
export async function createApplication(template = templateDefaultPath) {
const workspace = await createWorkspace();
await cp(template, workspace, {recursive: true});
await cp(resolve(join(FLECKS_CORE_ROOT, 'test'), template), workspace, {recursive: true});
return workspace;
}

View File

@ -116,6 +116,7 @@ export async function startServer({
opts = {},
path: request,
task,
template,
} = {}) {
let previousTimeout;
const start = Date.now();
@ -124,7 +125,7 @@ export async function startServer({
task.timeout(0);
}
const {socketPath, socketServer} = await socketListener();
const path = request || await createApplication();
const path = request || await createApplication(template);
if (beforeBuild) {
await beforeBuild({path, task});
}