(command, args, options = {})
| 26 | } |
| 27 | |
| 28 | export async function run(command, args, options = {}) { |
| 29 | const exec = commandForExecFile(command, args); |
| 30 | try { |
| 31 | const { stdout, stderr } = await execFileAsync(exec.command, exec.args, { |
| 32 | cwd: appRoot, |
| 33 | maxBuffer: 1024 * 1024 * 16, |
| 34 | ...exec.options, |
| 35 | ...options, |
| 36 | }); |
| 37 | if (stdout.trim()) console.log(stdout.trim()); |
| 38 | if (stderr.trim()) console.error(stderr.trim()); |
| 39 | } catch (error) { |
| 40 | const details = [error.stdout?.trim(), error.stderr?.trim(), error.message] |
| 41 | .filter(Boolean) |
| 42 | .join('\n'); |
| 43 | fail(`Command failed: ${basename(command)} ${args.join(' ')}\n${details}`); |
| 44 | } |
| 45 | } |
| 46 | |
| 47 | export async function tryRun(command, args, options = {}) { |
| 48 | const exec = commandForExecFile(command, args); |
no test coverage detected