"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.spawnExec = exports._spawnExec = void 0;
const node_child_process_1 = require("node:child_process");
function _spawnExec(command) {
    // https://nodejs.org/api/child_process.html#child_process_child_process_exec_command_options_callback
    // for reference, shell can be configed
    console.log('running:', command);
    const ex = (0, node_child_process_1.exec)(command);
    ex.on('exit', (code, signal) => {
        console.log(`spawn on exit code: ${code} signal: ${signal}`);
    });
    ex.on('close', (code, args) => {
        console.log(`spawn on close code: ${code} args: ${args}`);
    });
}
exports._spawnExec = _spawnExec;
function spawnExec(command, args) {
    const execProcess = (0, node_child_process_1.spawn)(command, args);
    console.log('spawn');
    console.log(execProcess.spawnfile);
    execProcess.on('spawn', () => {
        // console.log('spawn on spawn');
    });
    execProcess.stdout.on('data', data => {
        console.log(`spawn stdout: ${data}`);
    });
    execProcess.stderr.on('data', data => {
        console.log(`spawn on error ${data}`);
    });
    execProcess.on('exit', (code, signal) => {
        console.log(`spawn on exit code: ${code} signal: ${signal}`);
    });
    execProcess.on('close', (code, args) => {
        console.log(`spawn on close code: ${code} args: ${args}`);
    });
}
exports.spawnExec = spawnExec;
