Commands / CommandHandle
Interface: CommandHandle
Command execution handle.
It provides methods for waiting for the command to finish, retrieving stdout/stderr, and killing the command.
Implements
Omit<CommandResult,"exitCode"|"error">Partial<Pick<CommandResult,"exitCode"|"error">>
Properties
pid
readonlypid:number
process ID of the command.
Accessors
error
Get Signature
get error():
string|undefined
Error message from command execution.
Returns
string | undefined
Implementation of
exitCode
Get Signature
get exitCode():
number|undefined
Command execution exit code. 0 if the command finished successfully.
It is undefined if the command is still running.
Returns
number | undefined
Implementation of
stderr
Get Signature
get stderr():
string
Command execution stderr output.
Returns
string
Implementation of
stdout
Get Signature
get stdout():
string
Command execution stdout output.
Returns
string
Implementation of
Methods
closeStdin()
closeStdin(
opts?):Promise<void>
Close the command stdin.
This signals EOF to the command. The command must have been started with stdin: true.
Parameters
opts?
connection options.
Returns
Promise<void>
disconnect()
disconnect():
Promise<void>
Disconnect from the command.
The command is not killed, but SDK stops receiving events from the command. You can reconnect to the command using Commands.connect.
Once it returns, the onStdout/onStderr/onPty callbacks are guaranteed not to fire for output produced after this call. It does not wait for the event handler to drain, so it returns promptly even for an idle command whose stream produces no further output.
Returns
Promise<void>
kill()
kill():
Promise<boolean>
Kill the command. It uses SIGKILL signal to kill the command.
Returns
Promise<boolean>
true if the command was killed successfully, false if the command was not found.
sendStdin()
sendStdin(
data,opts?):Promise<void>
Send data to the command stdin.
The command must have been started with stdin: true.
Parameters
data
string | Uint8Array<ArrayBufferLike>
data to send to the command.
opts?
connection options.
Returns
Promise<void>
wait()
wait():
Promise<CommandResult>
Wait for the command to finish and return the result. If the command exits with a non-zero exit code, it throws a CommandExitError.
Returns
Promise<CommandResult>
CommandResult result of command execution.