UNPKG

@tapjs/run

Version:

Command-line interface for the node-tap runner

35 lines 1.32 kB
import { foregroundChild } from 'foreground-child'; import { fileURLToPath } from 'node:url'; import { resolveImport } from 'resolve-import'; import { mainCommand } from './main-config.js'; import { plugin } from './plugin.js'; const tapBuildBin = fileURLToPath(await resolveImport('@tapjs/test/generate-tap-test-class', import.meta.url)); const node = process.execPath; export const build = async (args, config) => { if (args.length !== 0) { throw new TypeError('build command does not take positional arguments'); } await plugin(['add', ...config.pluginList], config, true); const argv = [tapBuildBin, ...config.pluginList]; return new Promise((res, rej) => { foregroundChild(node, argv, {}, (code, signal) => { // if this is the main command, just terminate in the same way // otherwise, let the promise communicate the build status if (mainCommand === 'build') { res(); return; } if (code || signal) { rej(Object.assign(new Error('build failed'), { code, signal, })); } else { res(); } return false; }); }); }; //# sourceMappingURL=build.js.map