@@ -56692,7 +56692,7 @@ var supportsColor2 = {
5669256692var supports_color_default2 = supportsColor2;
5669356693
5669456694//
56695- import { spawn as _spawn, spawnSync as _spawnSync } from "child_process";
56695+ import { spawn as _spawn, spawnSync as _spawnSync, exec as _exec } from "child_process";
5669656696var ChildProcess = class {
5669756697 static spawnInteractive(command, args, options = {}) {
5669856698 return new Promise((resolve, reject) => {
@@ -56706,7 +56706,7 @@ var ChildProcess = class {
5670656706 return new Promise((resolve, reject) => {
5670756707 const commandText = `${command} ${args.join(" ")}`;
5670856708 const outputMode = options.mode;
56709- const env3 = getEnvironmentForNonInteractiveSpawn (options.env);
56709+ const env3 = getEnvironmentForNonInteractiveCommand (options.env);
5671056710 Log.debug(`Executing command: ${commandText}`);
5671156711 const childProcess = _spawn(command, args, { ...options, env: env3, shell: true, stdio: "pipe" });
5671256712 let logOutput = "";
@@ -56747,7 +56747,7 @@ ${logOutput}`);
5674756747 }
5674856748 static spawnSync(command, args, options = {}) {
5674956749 const commandText = `${command} ${args.join(" ")}`;
56750- const env3 = getEnvironmentForNonInteractiveSpawn (options.env);
56750+ const env3 = getEnvironmentForNonInteractiveCommand (options.env);
5675156751 Log.debug(`Executing command: ${commandText}`);
5675256752 const { status: exitCode, signal, stdout, stderr } = _spawnSync(command, args, { ...options, env: env3, encoding: "utf8", shell: true, stdio: "pipe" });
5675356753 const status = statusFromExitCodeAndSignal(exitCode, signal);
@@ -56756,11 +56756,50 @@ ${logOutput}`);
5675656756 }
5675756757 throw new Error(stderr);
5675856758 }
56759+ static exec(command, options = {}) {
56760+ return new Promise((resolve, reject) => {
56761+ var _a2, _b;
56762+ const outputMode = options.mode;
56763+ const env3 = getEnvironmentForNonInteractiveCommand(options.env);
56764+ Log.debug(`Executing command: ${command}`);
56765+ const childProcess = _exec(command, { ...options, env: env3 });
56766+ let logOutput = "";
56767+ let stdout = "";
56768+ let stderr = "";
56769+ (_a2 = childProcess.stderr) == null ? void 0 : _a2.on("data", (message) => {
56770+ stderr += message;
56771+ logOutput += message;
56772+ if (outputMode === void 0 || outputMode === "enabled") {
56773+ process.stderr.write(message);
56774+ }
56775+ });
56776+ (_b = childProcess.stdout) == null ? void 0 : _b.on("data", (message) => {
56777+ stdout += message;
56778+ logOutput += message;
56779+ if (outputMode === void 0 || outputMode === "enabled") {
56780+ process.stderr.write(message);
56781+ }
56782+ });
56783+ childProcess.on("close", (exitCode, signal) => {
56784+ const exitDescription = exitCode !== null ? `exit code "${exitCode}"` : `signal "${signal}"`;
56785+ const printFn = outputMode === "on-error" ? Log.error : Log.debug;
56786+ const status = statusFromExitCodeAndSignal(exitCode, signal);
56787+ printFn(`Command "${command}" completed with ${exitDescription}.`);
56788+ printFn(`Process output:
56789+ ${logOutput}`);
56790+ if (status === 0 || options.suppressErrorOnFailingExitCode) {
56791+ resolve({ stdout, stderr, status });
56792+ } else {
56793+ reject(outputMode === "silent" ? logOutput : void 0);
56794+ }
56795+ });
56796+ });
56797+ }
5675956798};
5676056799function statusFromExitCodeAndSignal(exitCode, signal) {
5676156800 return exitCode ?? signal ?? -1;
5676256801}
56763- function getEnvironmentForNonInteractiveSpawn (userProvidedEnv) {
56802+ function getEnvironmentForNonInteractiveCommand (userProvidedEnv) {
5676456803 const forceColorValue = supports_color_default2.stdout !== false ? supports_color_default2.stdout.level.toString() : void 0;
5676556804 return { FORCE_COLOR: forceColorValue, ...userProvidedEnv ?? process.env };
5676656805}
0 commit comments