A command that has finished executing. The exit code is immediately available and populated upon creation. Unlike Command, you don’t need to call wait() - the command has already completed execution.

Extends

Properties

exitCode

exitCode: number;
The exit code of the command. This is always populated for CommandFinished instances.

Overrides

Command.exitCode

Accessors

cmdId

Get Signature

get cmdId(): string;
ID of the command execution.
Returns
string

Inherited from

Command.cmdId

cwd

Get Signature

get cwd(): string;
Returns
string

Inherited from

Command.cwd

startedAt

Get Signature

get startedAt(): number;
Returns
number

Inherited from

Command.startedAt

Methods

logs()

logs(): AsyncIterable<{
  stream: "stdout" | "stderr";
  data: string;
}, any, any>;
Iterate over the output of this command.
for await (const log of cmd.logs()) {
  if (log.stream === "stdout") {
    process.stdout.write(log.data);
  } else {
    process.stderr.write(log.data);
  }
}

Returns

AsyncIterable<{ stream: "stdout" | "stderr"; data: string; }, any, any> An async iterable of log entries from the command output.

See

Command.stdout, Command.stderr, and Command.output to access output as a string.

Inherited from

Command.logs

output()

output(stream: "stdout" | "stderr" | "both"): Promise<string>;
Get the output of stdout, stderr, or both as a string. NOTE: This may throw string conversion errors if the command does not output valid Unicode.

Parameters

ParameterTypeDefault valueDescription
stream"stdout" | "stderr" | "both""both"The output stream to read: “stdout”, “stderr”, or “both”.

Returns

Promise<string> The output of the specified stream(s) as a string.

Inherited from

Command.output

stdout()

stdout(): Promise<string>;
Get the output of stdout as a string. NOTE: This may throw string conversion errors if the command does not output valid Unicode.

Returns

Promise<string> The standard output of the command.

Inherited from

Command.stdout

stderr()

stderr(): Promise<string>;
Get the output of stderr as a string. NOTE: This may throw string conversion errors if the command does not output valid Unicode.

Returns

Promise<string> The standard error output of the command.

Inherited from

Command.stderr

kill()

kill(signal?: Signal): Promise<void>;
Kill a running command in a sandbox.

Parameters

ParameterType
signal?Signal

Returns

Promise<void> Promise<void>.

Inherited from

Command.kill

wait()

wait(): Promise<CommandFinished>;
The wait method is not needed for CommandFinished instances since the command has already completed and exitCode is populated.

Returns

Promise<CommandFinished> This CommandFinished instance.

Deprecated

This method is redundant for CommandFinished instances. The exitCode is already available.

Overrides

Command.wait