2import { execFile, type ExecFileOptions } from 'child_process' 4export const aExecFile = util.promisify(execFile); 6type Do2ExecFileProps = { 12type ExecResult = { stdout: string; stderr: string; code?: number; isSuccess: boolean } 14export const do2ExecFile = async ({cmdA, isQuiet=true, opts}: Do2ExecFileProps): Promise<ExecResult> => { 16 console.log(cmdA.join(' ')) 19 const res = await aExecFile(cmdA[0], cmdA.slice(1), opts) 20 return {stdout: String(res.stdout), stderr: String(res.stderr), isSuccess: true} 22 const err = ee as { stdout?: string; stderr?: string; code?: number; message?: string } 23 const stderr = err.stderr || err.message || '' 24 return {stdout: err.stdout || '', stderr, code: err.code, isSuccess: false}