(command: string, args: string[])
| 97 | } |
| 98 | |
| 99 | const runCommand = (command: string, args: string[]): Promise<CliResult> => { |
| 100 | return new Promise((resolve, reject) => { |
| 101 | const child = spawn(command, args, { |
| 102 | cwd: projectRoot, |
| 103 | env: process.env, |
| 104 | stdio: 'pipe', |
| 105 | }) |
| 106 | |
| 107 | let stdout = '' |
| 108 | let stderr = '' |
| 109 | |
| 110 | child.stdout.on('data', (chunk) => { |
| 111 | stdout += chunk.toString() |
| 112 | }) |
| 113 | |
| 114 | child.stderr.on('data', (chunk) => { |
| 115 | stderr += chunk.toString() |
| 116 | }) |
| 117 | |
| 118 | child.on('error', reject) |
| 119 | child.on('close', (code) => { |
| 120 | resolve({ |
| 121 | code: code ?? 1, |
| 122 | stdout, |
| 123 | stderr, |
| 124 | }) |
| 125 | }) |
| 126 | }) |
| 127 | } |
| 128 | |
| 129 | describe('cli integration (spawn)', function () { |
| 130 | this.timeout(30000) |
no test coverage detected