(command, commandArgs, options = {})
| 47 | } |
| 48 | |
| 49 | function run(command, commandArgs, options = {}) { |
| 50 | const result = childProcess.spawnSync(command, commandArgs, { |
| 51 | cwd: options.cwd || process.cwd(), |
| 52 | encoding: 'utf8', |
| 53 | input: options.input, |
| 54 | stdio: options.inherit ? 'inherit' : ['pipe', 'pipe', 'pipe'], |
| 55 | }); |
| 56 | if (result.error) throw result.error; |
| 57 | if (result.status !== 0) { |
| 58 | throw new Error([ |
| 59 | `${command} ${commandArgs.join(' ')} failed with exit ${result.status}`, |
| 60 | result.stdout, |
| 61 | result.stderr, |
| 62 | ].filter(Boolean).join('\n')); |
| 63 | } |
| 64 | return result.stdout || ''; |
| 65 | } |
| 66 | |
| 67 | function gh(args, options = {}) { |
| 68 | return run('gh', args, options).trim(); |
no outgoing calls
no test coverage detected