Skip to content

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

ParameterTypeDescription
argsstring | string[]Command and arguments (or a single string if shell=true)
options?SubprocessOptionsSubprocess options

Returns

CompletedProcess

CompletedProcess with exit code and captured output

Example

// Run a simple command
const result = run(["ls", "-la"])
// Run with shell
const result = run("echo hello && echo world", { shell: true })
// Capture output
const result = run(["git", "status"], { stdout: PIPE })
console.log(result.stdout)
// Check for errors
const result = run(["false"], { check: true }) // Throws CalledProcessError