| @@ -203,7 +203,7 @@ const buildWrapperPackage = async (binaries: Record<string, string>) => { · 202 unmodified lines |
| 203 | 203 | await chmod(join(binDir, "executor"), 0o755); |
| 204 | 204 | |
| 205 | 205 | // Postinstall downloads the matching release asset from GitHub Releases |
| 206 | | − await writeFile(join(wrapperDir, "postinstall.mjs"), POSTINSTALL_SCRIPT); |
| 206 | + await writeFile(join(wrapperDir, "postinstall.cjs"), POSTINSTALL_SCRIPT); |
| 207 | 207 | |
| 208 | 208 | // Package.json |
| 209 | 209 | await writeFile( |
| @@ -220,7 +220,7 @@ const buildWrapperPackage = async (binaries: Record<string, string>) => { · 10 unmodified lines |
| 220 | 220 | license: meta.license, |
| 221 | 221 | bin: { executor: "bin/executor" }, |
| 222 | 222 | scripts: { |
| 223 | | − postinstall: "node ./postinstall.mjs", |
| 223 | + postinstall: "node ./postinstall.cjs", |
| 224 | 224 | }, |
| 225 | 225 | engines: { |
| 226 | 226 | node: ">=20", |
| @@ -339,7 +339,36 @@ if (process.env.EXECUTOR_BIN_PATH) run(process.env.EXECUTOR_BIN_PATH); · 112 unmodified lines |
| 339 | 339 | |
| 340 | 340 | const scriptDir = path.dirname(fs.realpathSync(__filename)); |
| 341 | 341 | const cached = path.join(scriptDir, process.platform === "win32" ? ".executor.exe" : ".executor"); |
| 342 | | −if (!fs.existsSync(cached)) { |
| 342 | + |
| 343 | +const installIfNeeded = () => { |
| 344 | + if (fs.existsSync(cached)) { |
| 345 | + return true; |
| 346 | + } |
| 347 | + |
| 348 | + const installer = path.resolve(scriptDir, "..", "postinstall.cjs"); |
| 349 | + if (!fs.existsSync(installer)) { |
| 350 | + return false; |
| 351 | + } |
| 352 | + |
| 353 | + console.error("executor binary is missing; downloading release asset..."); |
| 354 | + const result = childProcess.spawnSync(process.execPath, [installer], { |
| 355 | + stdio: "inherit", |
| 356 | + env: process.env, |
| 357 | + }); |
| 358 | + |
| 359 | + if (result.error) { |
| 360 | + console.error(result.error.message); |
| 361 | + process.exit(1); |
| 362 | + } |
| 363 | + |
| 364 | + if (typeof result.status === "number" && result.status !== 0) { |
| 365 | + process.exit(result.status); |
| 366 | + } |
| 367 | + |
| 368 | + return fs.existsSync(cached); |
| 369 | +}; |
| 370 | + |
| 371 | +if (!installIfNeeded()) { |
| 343 | 372 | console.error("executor binary is missing. Reinstall the package or run 'npm rebuild executor'."); |
| 344 | 373 | process.exit(1); |
| 345 | 374 | } |