Overview
Exec steps must be wrapped in a task. They return a promise that resolves when the command is complete.
Example
Piping
You can pipe the output of one command to another by using template literals.
We automatically escape the output of the command to prevent command injection.
Global Exec
You can create a "global" exec by calling the $
function without a string.
Methods
exec.cwd
The cwd
method allows you to change the current working directory for the command.
nothrow
The nothrow
method allows you to ignore errors from the command.
throws
The throws
method allows you to throw an error if the command fails.
env
The env
method allows you to set environment variables for the command.
Returns
The promise returned by the exec step resolves with the output of the command as an object with the following properties:
stdout
- Type: Uint8Array
The standard output of the command.
stderr
- Type: Uint8Array
The standard error of the command.
stdall
- Type: Uint8Array
The combined standard output and standard error of the command.
exitCode
- Type: number
The exit code of the command.
text
- Type: (encoding?: string = "utf-8") => string
A method that returns the output as a string.
json
- Type: <T>() => T
A method that returns the output as a JSON object.
lines
- Type: (encoding?: string = "utf-8") => string[]
A method that returns the output as an array of lines.
Options
You can use also use an object to pass options to the exec step.
- cwd - The current working directory for the command.
- throws - Throw an error if the command fails. Defaults to true.
- nothrow - Ignore errors from the command. Defaults to false.