A command that has finished executing. Contains the exit code of the command.

Extends

Properties

exitCode

exitCode: number;
The exit code of the command, if available. This is set after wait has returned.

Accessors

cmdId

Get Signature

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

Inherited from

Command.cmdId

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

wait()

wait(): Promise<CommandFinished>;
Wait for a command to exit and populate its exit code.
await cmd.wait()
if (cmd.exitCode != 0) {
  console.error("Something went wrong...")
}

Returns

Promise<CommandFinished> A CommandFinished instance with populated exit code.

Inherited from

Command.wait

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