run
run(
args:string|string[],options?:SubprocessOptions):CompletedProcess
Defined in: packages/pythonlib/src/subprocess.ts:138
Run a command and wait for it to complete.
Parameters
| Parameter | Type | Description |
|---|---|---|
args | string | string[] | Command and arguments (or a single string if shell=true) |
options? | SubprocessOptions | Subprocess options |
Returns
CompletedProcess with exit code and captured output
Example
// Run a simple commandconst result = run(["ls", "-la"])
// Run with shellconst result = run("echo hello && echo world", { shell: true })
// Capture outputconst result = run(["git", "status"], { stdout: PIPE })console.log(result.stdout)
// Check for errorsconst result = run(["false"], { check: true }) // Throws CalledProcessError