function handleExecFile()

in cli-functions.js [33:64]


function handleExecFile(command, args, options = {}) {
  return new Promise((resolve, reject) => {
    const child = execFile(command, args, options);

    let stdoutData = '';
    let stderrData = '';

    child.stdout.on('data', (data) => {
      stdoutData += data;
    });

    child.stderr.on('data', (data) => {
      stderrData += data;
    });

    child.on('error', (error) => {
      logger.error(`Error spawning child process: ${error.message}`);
      reject(`Error spawning child process: ${error.message}`);
    });

    child.on('close', (code) => {
      if (code !== 0) {
        const errorMessage = `Process exited with code ${code}\n${stderrData}`;
        logger.error(errorMessage);
        reject(errorMessage);
      } else {
        const output = (stdoutData + stderrData).trim();
        resolve(output);
      }
    });
  });
}