exec
exec starts one external program and connects its standard descriptors to bounded byte streams.
Signature
exec(command: string, args?: string[]): Result<ChildProcess, ProcessError>Parameters
| Parameter | Type | Purpose |
|---|---|---|
command | string | Executable path or command name. |
args | string[]? | Individual arguments, or an omitted empty list. |
Usage and errors
tyrus
import { ChildProcess, ProcessError, exec } from "tyrus:process";
async function run(): Promise<Result<i32, ProcessError>> {
const child: ChildProcess = exec("tool", ["--version"])?;
await child.stdin.close();
return await child.wait();
}error
tyrus
const child: ChildProcess = exec("tool", "--version"); Each argument is passed directly to the program. exec does not parse shell quoting, redirections, or pipelines. A start-time failure returns Err(ProcessError).
