| 160 | } |
| 161 | |
| 162 | async function runFinalCheckCommands( |
| 163 | commands: string[], |
| 164 | cwd: string, |
| 165 | env?: Record<string, string>, |
| 166 | ): Promise<FinalCheckOutput[]> { |
| 167 | const results: FinalCheckOutput[] = [] |
| 168 | |
| 169 | for (const command of commands) { |
| 170 | console.log(` Running: ${command}`) |
| 171 | try { |
| 172 | const { stdout, stderr } = await execAsync(command, { |
| 173 | cwd, |
| 174 | encoding: 'utf-8', |
| 175 | maxBuffer: 10 * 1024 * 1024, // 10MB buffer |
| 176 | env: { ...process.env, ...env }, |
| 177 | }) |
| 178 | results.push({ |
| 179 | command, |
| 180 | exitCode: 0, |
| 181 | stdout, |
| 182 | stderr, |
| 183 | }) |
| 184 | console.log(` ✓ Command succeeded: ${command}`) |
| 185 | } catch (error: any) { |
| 186 | // Command failed, but we still capture the output |
| 187 | results.push({ |
| 188 | command, |
| 189 | exitCode: error.code || 1, |
| 190 | stdout: error.stdout || '', |
| 191 | stderr: error.stderr || error.message || '', |
| 192 | }) |
| 193 | console.log(` ✗ Command failed (exit ${error.code}): ${command}`) |
| 194 | } |
| 195 | } |
| 196 | |
| 197 | return results |
| 198 | } |