@tapjs/run
Version:
Command-line interface for the node-tap runner
35 lines • 1.35 kB
JavaScript
import { foregroundChild } from 'foreground-child';
import { fileURLToPath } from 'node:url';
import { resolveImportSync } from 'resolve-import/resolve-import-sync';
import { mainCommand } from './main-config.js';
import { plugin } from './plugin.js';
const tapBuildBin = fileURLToPath(resolveImportSync('@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