@kungfu-tech/buildchain 3.0.2-alpha.0 → 3.0.2-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -114,10 +114,24 @@ export function prepareGateExecutionFiles(files) {
114
114
  for (const file of files) fs.rmSync(file, { force: true });
115
115
  }
116
116
 
117
+ export function commandSpawnOptions({
118
+ cwd,
119
+ env = process.env,
120
+ streamOutput = false,
121
+ } = {}) {
122
+ if (streamOutput) return { cwd, env, stdio: "inherit" };
123
+ return {
124
+ cwd,
125
+ env,
126
+ encoding: "utf8",
127
+ maxBuffer: 16 * 1024 * 1024,
128
+ };
129
+ }
130
+
117
131
  function runArgv(
118
132
  argv,
119
133
  args,
120
- { cwd, env = process.env, allowFailure = false } = {},
134
+ { cwd, env = process.env, allowFailure = false, streamOutput = false } = {},
121
135
  ) {
122
136
  const command = argv[0];
123
137
  const commandArgs = [...argv.slice(1), ...args];
@@ -126,25 +140,12 @@ function runArgv(
126
140
  const batchInvocation = windowsBatch
127
141
  ? windowsBatchInvocation(command, commandArgs, { cwd })
128
142
  : null;
143
+ const spawnOptions = commandSpawnOptions({ cwd, env, streamOutput });
129
144
  const result = windowsBatch
130
- ? spawnSync(
131
- batchInvocation.command,
132
- batchInvocation.args,
133
- {
134
- cwd,
135
- env,
136
- encoding: "utf8",
137
- maxBuffer: 16 * 1024 * 1024,
138
- },
139
- )
140
- : spawnSync(command, commandArgs, {
141
- cwd,
142
- env,
143
- encoding: "utf8",
144
- maxBuffer: 16 * 1024 * 1024,
145
- });
146
- if (result.stdout) process.stdout.write(result.stdout);
147
- if (result.stderr) process.stderr.write(result.stderr);
145
+ ? spawnSync(batchInvocation.command, batchInvocation.args, spawnOptions)
146
+ : spawnSync(command, commandArgs, spawnOptions);
147
+ if (!streamOutput && result.stdout) process.stdout.write(result.stdout);
148
+ if (!streamOutput && result.stderr) process.stderr.write(result.stderr);
148
149
  if (result.error) throw result.error;
149
150
  const status = result.status ?? 1;
150
151
  if (!allowFailure && status !== 0)
@@ -257,7 +258,12 @@ function runMode() {
257
258
  ],
258
259
  registry,
259
260
  );
260
- const runResult = runArgv(argv, runArgs, { cwd, env, allowFailure: true });
261
+ const runResult = runArgv(argv, runArgs, {
262
+ cwd,
263
+ env,
264
+ allowFailure: true,
265
+ streamOutput: true,
266
+ });
261
267
  let receipt = fs.existsSync(receiptPath)
262
268
  ? readJson(receiptPath, "Shifu gate receipt")
263
269
  : null;