fix(release): preserve npm pack json output · openclaw/openclaw@7421400
vincentkoc
·
2026-06-24
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -117,17 +117,29 @@ export function resolvePrepackCommandTimeoutMs(env: NodeJS.ProcessEnv = process.
|
117 | 117 | ); |
118 | 118 | } |
119 | 119 | |
| 120 | +export function resolvePrepackCommandStdio( |
| 121 | +options: SpawnSyncOptions, |
| 122 | +env: NodeJS.ProcessEnv = process.env, |
| 123 | +): SpawnSyncOptions["stdio"] { |
| 124 | +const requestedStdio = options.stdio ?? "inherit"; |
| 125 | +const npmJsonOutput = env.npm_config_json === "true" || env.npm_config_json === "1"; |
| 126 | +if (npmJsonOutput && requestedStdio === "inherit") { |
| 127 | +return ["inherit", 2, "inherit"]; |
| 128 | +} |
| 129 | +return requestedStdio; |
| 130 | +} |
| 131 | + |
120 | 132 | export function runPrepackCommand( |
121 | 133 | command: string, |
122 | 134 | args: string[], |
123 | 135 | options: SpawnSyncOptions = {}, |
124 | 136 | ): ReturnType<typeof spawnSync> { |
125 | 137 | const env = options.env ?? process.env; |
126 | 138 | return spawnSync(command, args, { |
127 | | -stdio: "inherit", |
128 | 139 | ...options, |
129 | 140 | env, |
130 | 141 | killSignal: options.killSignal ?? "SIGKILL", |
| 142 | +stdio: resolvePrepackCommandStdio(options, env), |
131 | 143 | timeout: options.timeout ?? resolvePrepackCommandTimeoutMs(env), |
132 | 144 | }); |
133 | 145 | } |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -2,6 +2,7 @@
|
2 | 2 | import { describe, expect, it } from "vitest"; |
3 | 3 | import { |
4 | 4 | collectPreparedPrepackErrors, |
| 5 | +resolvePrepackCommandStdio, |
5 | 6 | resolvePrepackCommandTimeoutMs, |
6 | 7 | runPrepackCommand, |
7 | 8 | } from "../scripts/openclaw-prepack.ts"; |
@@ -26,6 +27,20 @@ describe("collectPreparedPrepackErrors", () => {
|
26 | 27 | }); |
27 | 28 | |
28 | 29 | describe("runPrepackCommand", () => { |
| 30 | +it("keeps prepack child stdout off npm pack JSON stdout", () => { |
| 31 | +expect(resolvePrepackCommandStdio({ stdio: "inherit" }, { npm_config_json: "true" })).toEqual([ |
| 32 | +"inherit", |
| 33 | +2, |
| 34 | +"inherit", |
| 35 | +]); |
| 36 | +expect( |
| 37 | +resolvePrepackCommandStdio( |
| 38 | +{ stdio: ["ignore", "pipe", "pipe"] }, |
| 39 | +{ npm_config_json: "true" }, |
| 40 | +), |
| 41 | +).toEqual(["ignore", "pipe", "pipe"]); |
| 42 | +}); |
| 43 | + |
29 | 44 | it("returns captured output for successful commands", () => { |
30 | 45 | const result = runPrepackCommand(process.execPath, ["--eval", "process.stdout.write('ok')"], { |
31 | 46 | encoding: "utf8", |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。