* Install binaries specified in binInstalls config to a temporary directory * Returns the temporary directory path and updated env with PATH
(binInstalls: EvalDataV2['binInstalls'])
| 267 | * Returns the temporary directory path and updated env with PATH |
| 268 | */ |
| 269 | function installBinaries(binInstalls: EvalDataV2['binInstalls']): { |
| 270 | tempDir: string | null |
| 271 | env: Record<string, string> |
| 272 | } { |
| 273 | if (!binInstalls || binInstalls.length === 0) { |
| 274 | return { tempDir: null, env: {} } |
| 275 | } |
| 276 | |
| 277 | const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'codebuff-bins-')) |
| 278 | |
| 279 | const binPaths: string[] = [] |
| 280 | |
| 281 | for (const bin of binInstalls) { |
| 282 | try { |
| 283 | execSync(bin.installScript, { |
| 284 | cwd: tempDir, |
| 285 | stdio: 'ignore', |
| 286 | env: { ...process.env, INSTALL_DIR: tempDir }, |
| 287 | }) |
| 288 | |
| 289 | const fullBinPath = path.join(tempDir, bin.binPath) |
| 290 | if (fs.existsSync(fullBinPath)) { |
| 291 | binPaths.push(path.dirname(fullBinPath)) |
| 292 | console.log(`✓ ${bin.name} installed at ${fullBinPath}`) |
| 293 | } else { |
| 294 | console.warn( |
| 295 | `Warning: Expected binary not found at ${fullBinPath} after installing ${bin.name}`, |
| 296 | ) |
| 297 | } |
| 298 | } catch (error) { |
| 299 | console.error(`Error installing ${bin.name}:`, error) |
| 300 | throw error |
| 301 | } |
| 302 | } |
| 303 | |
| 304 | // Prepend all bin paths to PATH |
| 305 | const updatedPath = [...binPaths, process.env.PATH].filter(Boolean).join(':') |
| 306 | |
| 307 | return { |
| 308 | tempDir, |
| 309 | env: { PATH: updatedPath }, |
| 310 | } |
| 311 | } |
| 312 | |
| 313 | interface CommitWithSource { |
| 314 | commit: EvalCommitV2 |