From b1876b60ddc9eeb66e16b85ba1f1ca2e7c4fe3e9 Mon Sep 17 00:00:00 2001 From: stantheman0128 Date: Tue, 4 Aug 2026 02:11:54 +0800 Subject: [PATCH] fix(npm): propagate the CLI exit code from the npm wrapper execFileSync throws when the binary exits non-zero, so `npx zeabur` printed a Node stack trace and always exited 1. That hides the exit code that `service exec` and `server exec` deliberately return from the remote command, which breaks scripting and CI usage. spawnSync returns the status instead of throwing, so the wrapper can forward it unchanged and report a spawn failure in a single line. Co-authored-by: Cursor --- npm/index.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/npm/index.js b/npm/index.js index 370f309..3283fb2 100755 --- a/npm/index.js +++ b/npm/index.js @@ -1,6 +1,6 @@ #!/usr/bin/env node -import { execFileSync } from "child_process"; +import { spawnSync } from "child_process"; import os from "os"; import { fileURLToPath } from "url"; @@ -40,5 +40,14 @@ function getArch() { const pathToBinary = fileURLToPath(new URL(`./zeabur_${platform}_${arch}/zeabur${platform === "windows" ? ".exe" : ""}`, import.meta.url)); const args = process.argv.slice(2); - execFileSync(pathToBinary, args, { stdio: "inherit" }); + const result = spawnSync(pathToBinary, args, { stdio: "inherit" }); + + if (result.error) { + console.error(`Failed to run ${pathToBinary}: ${result.error.message}`); + process.exitCode = 1; + return; + } + + // status is null when the binary was terminated by a signal. + process.exitCode = result.status === null ? 1 : result.status; })()