/** * @file * * Contains utility functions for executing commands. */ /** * A command part: either a plain string or an {@link ExecArgument} with batched arguments. */ export type CommandPart = ExecArgument | string; /** * A command argument that contains a list of commandArguments to be batched. * If the expanded command exceeds the platform's max command length, * the batched commandArguments are split into sequential executions. */ export interface ExecArgument { /** * The arguments to batch. */ readonly batchedArguments: readonly string[]; } /** * Options for {@link exec} that return detailed results. */ export interface ExecDetailedOptions extends ExecOption { /** * Must be `true` to receive detailed results. */ readonly shouldIncludeDetails: true; } /** * Options for executing a command. */ export interface ExecOption { /** * A current working folder for the command execution. */ readonly cwd?: string; /** * If `true`, suppresses the output of the command. */ readonly isQuiet?: boolean; /** * If `true`, ignores the exit code of the command. */ readonly shouldIgnoreExitCode?: boolean; /** * If `true`, returns detailed results. */ readonly shouldIncludeDetails?: boolean; /** * An argument to be passed to the command. */ readonly stdin?: string; /** * Timeout in milliseconds. The child process is killed if it exceeds this. */ readonly timeoutInMilliseconds?: number; } /** * A result of {@link exec}. */ export interface ExecResult { /** * An exit code of the command. A value of `null` indicates that the process did not exit normally. */ readonly exitCode: null | number; /** * A signal that caused the process to be terminated. A value of `null` indicates that no signal was received. */ readonly exitSignal: NodeJS.Signals | null; /** * A standard error output from the command. */ readonly stderr: string; /** * A standard output from the command. */ readonly stdout: string; } /** * Options for {@link exec} that return only stdout. */ export interface ExecSimpleOptions extends ExecOption { /** * Must be `false` or omitted to receive only stdout. */ readonly shouldIncludeDetails?: false; } /** * Executes a command. * * @param command - The command to execute. It can be a string or an array of strings. * @param options - The options for the execution. * @returns A {@link Promise} that resolves with the output of the command. */ export declare function exec(command: CommandPart[] | string, options?: ExecSimpleOptions): Promise; /** * Executes a command. * * @param command - The command to execute. It can be a string or an array of strings. * @param options - The options for the execution. * @returns A {@link Promise} that resolves with ExecResult object. */ export declare function exec(command: CommandPart[] | string, options: ExecDetailedOptions): Promise; /** * Converts an array of command-line arguments into a single command-line string * using the `CommandLineToArgvW` convention. * * @param commandArguments - The array of command-line arguments to convert. * @returns A string representing the command-line invocation. */ export declare function toCommandLine(commandArguments: string[]): string;