fix: tee artifact download progress live
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { spawn, spawnSync } from "node:child_process";
|
||||
import { appendFileSync, closeSync, createWriteStream, existsSync, openSync, readSync, statSync } from "node:fs";
|
||||
import { closeSync, createWriteStream, existsSync, openSync, readSync, statSync } from "node:fs";
|
||||
|
||||
export interface CommandResult {
|
||||
command: string[];
|
||||
@@ -11,7 +11,7 @@ export interface CommandResult {
|
||||
timedOut: boolean;
|
||||
}
|
||||
|
||||
export function runCommand(command: string[], cwd: string, options: { timeoutMs?: number; env?: NodeJS.ProcessEnv; teeStdoutFile?: string; teeStderrFile?: string } = {}): CommandResult {
|
||||
export function runCommand(command: string[], cwd: string, options: { timeoutMs?: number; env?: NodeJS.ProcessEnv } = {}): CommandResult {
|
||||
const result = spawnSync(command[0], command.slice(1), {
|
||||
cwd,
|
||||
encoding: "utf8",
|
||||
@@ -20,9 +20,7 @@ export function runCommand(command: string[], cwd: string, options: { timeoutMs?
|
||||
timeout: options.timeoutMs,
|
||||
});
|
||||
const error = result.error as (Error & { code?: string }) | undefined;
|
||||
if (options.teeStdoutFile !== undefined && result.stdout !== undefined && result.stdout.length > 0) appendFileSync(options.teeStdoutFile, result.stdout, "utf8");
|
||||
const stderr = result.stderr ?? error?.message ?? "";
|
||||
if (options.teeStderrFile !== undefined && stderr.length > 0) appendFileSync(options.teeStderrFile, stderr, "utf8");
|
||||
return {
|
||||
command,
|
||||
cwd,
|
||||
|
||||
Reference in New Issue
Block a user