@vigilbase/cli
Version:
Vigilbase CLI — security scanners, agent tools, and Vigilbase One from the terminal.
19 lines (18 loc) • 817 B
JavaScript
import { runCli } from './cli.js';
import { configureSystemTrust } from './lib/system-trust.js';
// A reader that stops early (`| head`) closes the pipe, which is fine; any other write error loses output.
let isOutputLost = false;
for (const stream of [process.stdout, process.stderr]) {
stream.on('error', (error) => {
if (error.code !== 'EPIPE')
isOutputLost = true;
});
}
configureSystemTrust();
const code = await runCli();
// Writes to a pipe are asynchronous: wait until both streams have drained, or process.exit drops the rest.
await Promise.all([process.stdout, process.stderr].map((stream) => new Promise((resolve) => {
stream.write('', () => resolve());
})));
process.exit(isOutputLost || typeof code !== 'number' || !Number.isInteger(code) ? 1 : code);