Skip to content

Commit 5ee1a94

Browse files
committed
dist update
1 parent aa5b939 commit 5ee1a94

File tree

4 files changed

+16
-11
lines changed

4 files changed

+16
-11
lines changed

dist/tools/libs/agents.mjs

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { exec } from 'node:child_process';
1+
import { execFile } from 'node:child_process';
22
import * as fs from 'node:fs/promises';
33
import * as process from 'node:process';
44
import * as path from 'node:path';
@@ -171,23 +171,28 @@ class BuildAgentBase {
171171
return toolPath;
172172
}
173173
async exec(cmd, args) {
174-
const exec$1 = util.promisify(exec);
174+
const execFile$1 = util.promisify(execFile);
175175
try {
176176
const commandOptions = { maxBuffer: 1024 * 1024 * 10 };
177-
const { stdout, stderr } = await exec$1(`${cmd} ${args.join(" ")}`, commandOptions);
177+
const { stdout, stderr } = await execFile$1(cmd, args, commandOptions);
178+
const normalizedStdout = typeof stdout === "string" ? stdout : stdout?.toString();
179+
const normalizedStderr = typeof stderr === "string" ? stderr : stderr?.toString();
178180
return {
179181
code: 0,
180182
error: null,
181-
stderr,
182-
stdout
183+
stderr: normalizedStderr,
184+
stdout: normalizedStdout
183185
};
184186
} catch (e) {
185187
const error = e;
188+
const normalizedStdout = typeof error.stdout === "string" ? error.stdout : error.stdout?.toString();
189+
const normalizedStderr = typeof error.stderr === "string" ? error.stderr : error.stderr?.toString() ?? error.message;
190+
const exitCode = typeof error.code === "number" ? error.code : -1;
186191
return {
187-
code: error.code,
192+
code: exitCode,
188193
error,
189-
stderr: error.stderr,
190-
stdout: error.stdout
194+
stderr: normalizedStderr,
195+
stdout: normalizedStdout
191196
};
192197
}
193198
}

0 commit comments

Comments
 (0)