putout
Version:
🐊 Pluggable and configurable code transformer with built-in ESLint, Babel and support of js, jsx, typescript, flow, markdown, yaml and json
39 lines (32 loc) • 824 B
JavaScript
import {Worker} from 'node:worker_threads';
import process, {
cwd,
stdout,
exit as halt,
} from 'node:process';
import {subscribe} from '@putout/engine-reporter/subscribe';
import {parseArgs} from '../lib/cli/parse-args.js';
import {createExit} from '../lib/cli/exit.mjs';
import {dropInteractive} from './drop-interactive.mjs';
const args = parseArgs(process.argv.slice(2));
const write = stdout.write.bind(stdout);
if (!args.worker) {
await import('./putout.mjs');
halt();
}
const slave = new URL('./putout.mjs', import.meta.url);
const worker = new Worker(slave, {
workerData: dropInteractive(process.argv),
stdin: true,
});
await subscribe({
args,
worker,
cwd,
write,
exit: createExit({
halt,
logError: console.error,
}),
});