vael:exec
Argv-only subprocess execution, PATH executable lookup, and OS advisory file locking.
Available in the vjs (vaeljs) runtime (exec, execSync, run,
runSync, spawn, which, whichSync, whichAll, whichAllSync,
lockFile, lockFileSync, cmd, Command, ChildProcess, Output,
CommandError, NotFoundOnPathError, FileLock); vjs-lite
(vaeljs-lite) exposes the synchronous APIs only.
Never invokes a shell (sh -c or cmd.exe /c). All program names,
arguments, working directories, and environment entries are validated against
NUL bytes and invalid structure before spawning.
import ... from "vael:exec"
vael-exec (enabled by default in vaeljs-core and vaeljs-lite-core)exec, run, spawn, which, whichAll, lockFile, ChildProcess, PathFinder.findExe) are V8-only (vjs). Sync APIs (Command, cmd, execSync, runSync, whichSync, whichAllSync, lockFileSync, PathFinder, pathFinder, addLogger, clearLoggers) run on both vjs and vjs-lite.Example
Section titled “Example”import { cmd, exec, execSync, lockFileSync, whichSync } from "vael:exec";
const sh = whichSync("sh");if (sh !== null) { const out = execSync([sh, "-c", "echo hello"]).validate(); console.log(out.text().trim());}
const asyncOut = await exec(cmd("echo").arg("world"));console.log(asyncOut.lines());
using lock = lockFileSync("./app.lock");console.log(lock.mode);cmdv0.0.0-alpha.2Command builder without executing it.execvjs onlyv0.0.0-alpha.2stdout and stderr (defaulting stdin to "null" and stdout/stderr to "piped").execSyncv0.0.0-alpha.2stdout and stderr (defaulting stdin to "null" and stdout/stderr to "piped").runvjs onlyv0.0.0-alpha.2runSyncv0.0.0-alpha.2spawnvjs onlyv0.0.0-alpha.2Command as a managed ChildProcess handle with piped streams by default.whichvjs onlyv0.0.0-alpha.2name on PATH (optionally prepended by prependPath).whichSyncv0.0.0-alpha.2name on PATH (optionally prepended by prependPath).whichAllvjs onlyv0.0.0-alpha.2name across prependPath and PATH in search order.whichAllSyncv0.0.0-alpha.2name across prependPath and PATH in search order.lockFilevjs onlyv0.0.0-alpha.2path (rejecting symbolic links).lockFileSyncv0.0.0-alpha.2path (rejecting symbolic links).addLoggerv0.0.0-alpha.2clearLoggersv0.0.0-alpha.2CommandErrorv0.0.0-alpha.2Output.validate() or vael:exec operations when a subprocess exits with a non-zero status code, signal termination, ti...NotFoundOnPathErrorv0.0.0-alpha.2PATH or at an explicit path (code: "VAEL_EXEC_NOT_FOUND").Outputv0.0.0-alpha.2exec, execSync, and ChildProcess.waitWithOutput.Commandv0.0.0-alpha.2ChildProcessvjs onlyv0.0.0-alpha.2spawn.FileLockv0.0.0-alpha.2lockFile and lockFileSync.PathFinderv0.0.0-alpha.2CommandOptionsv0.0.0-alpha.2Command, cmd, exec, execSync, run, runSync, and spawn.CommandLogEventv0.0.0-alpha.2CommandLogHandler before a subprocess spawns.CommandLogSubscriptionv0.0.0-alpha.2addLogger and Command.addLogger.PathFinderOptionsv0.0.0-alpha.2PathFinder registry.CommandStatusv0.0.0-alpha.2run, runSync, ChildProcess.tryWait, and ChildProcess.wait.LockOptionsv0.0.0-alpha.2lockFile and lockFileSync.CommandErrorOptionsv0.0.0-alpha.2CommandError.ExecErrorCodev0.0.0-alpha.2VAEL_EXEC_* error codes exposed on Error.code by vael:exec operations.StdioModev0.0.0-alpha.2stdin, stdout, and stderr.Signalv0.0.0-alpha.2LockModev0.0.0-alpha.2CommandLogHandlerv0.0.0-alpha.2Functions
Section titled “Functions”export function cmd(program: string, options?: CommandOptions): Command;
export function cmd(
program: string,
args: readonly string[],
options?: CommandOptions,
): Command;
export function cmd(argv: readonly string[], options?: CommandOptions): Command;
Create a fluent Command builder without executing it.
cmd(program, options?)| Name | Type | Description |
|---|---|---|
program | string | Executable name/path or [program, ...args] array. |
options optional | CommandOptions | Optional command configuration when argsOrOptions is an argument array. |
Command — Configured Command builder.cmd(program, args, options?)| Name | Type | Description |
|---|---|---|
program | string | — |
args | readonly string[] | — |
options optional | CommandOptions | — |
cmd(argv, options?)| Name | Type | Description |
|---|---|---|
argv | readonly string[] | — |
options optional | CommandOptions | — |
Error— ("VAEL_EXEC_INVALID_ARGUMENT") ifprogramis empty or contains NUL bytes.
import { cmd, execSync } from "vael:exec";
const command = cmd("env").envClear().env("FOO", "bar");console.log(command.toArgs());export function exec(command: Command): Promise<Output>;
export function exec(argv: readonly string[], options?: CommandOptions): Promise<Output>;
export function exec(program: string, options?: CommandOptions): Promise<Output>;
export function exec(
program: string,
args: readonly string[],
options?: CommandOptions,
): Promise<Output>;
Execute a command asynchronously and capture stdout and stderr
(defaulting stdin to "null" and stdout/stderr to "piped").
Available in vjs (vaeljs) only; use execSync in vjs-lite.
exec(command)| Name | Type | Description |
|---|---|---|
command | Command | Configured Command builder. |
exec(argv, options?)Execute an [program, ...args] argv array asynchronously and capture stdout and stderr.
| Name | Type | Description |
|---|---|---|
argv | readonly string[] | Non-empty [program, ...args] array (never shell-expanded). |
options optional | CommandOptions | Optional working directory, environment, stdio, and limits. |
exec(program, options?)Execute program asynchronously with optional CommandOptions.
| Name | Type | Description |
|---|---|---|
program | string | Executable name or path. |
options optional | CommandOptions | Optional arguments, working directory, environment, stdio, and limits. |
exec(program, args, options?)Execute program with args asynchronously and capture stdout and stderr.
| Name | Type | Description |
|---|---|---|
program | string | Executable name or path. |
args | readonly string[] | Literal argv arguments. |
options optional | CommandOptions | Optional working directory, environment, stdio, and limits. |
NotFoundOnPathError— if the executable cannot be found.Error— withcode: ExecErrorCodeon invalid arguments, timeout, or output overflow.
execSync
Section titled “execSync”export function execSync(command: Command): Output;
export function execSync(argv: readonly string[], options?: CommandOptions): Output;
export function execSync(program: string, options?: CommandOptions): Output;
export function execSync(
program: string,
args: readonly string[],
options?: CommandOptions,
): Output;
Execute a command synchronously and capture stdout and stderr
(defaulting stdin to "null" and stdout/stderr to "piped").
Available in both vjs (vaeljs) and vjs-lite (vaeljs-lite).
execSync(command)| Name | Type | Description |
|---|---|---|
command | Command | Configured Command builder. |
Output — Captured Output.execSync(argv, options?)Execute an [program, ...args] argv array synchronously and capture stdout and stderr.
| Name | Type | Description |
|---|---|---|
argv | readonly string[] | Non-empty [program, ...args] array (never shell-expanded). |
options optional | CommandOptions | Optional working directory, environment, stdio, and limits. |
Output — Captured Output.execSync(program, options?)Execute program synchronously with optional CommandOptions.
| Name | Type | Description |
|---|---|---|
program | string | Executable name or path. |
options optional | CommandOptions | Optional arguments, working directory, environment, stdio, and limits. |
Output — Captured Output.execSync(program, args, options?)Execute program with args synchronously and capture stdout and stderr.
| Name | Type | Description |
|---|---|---|
program | string | Executable name or path. |
args | readonly string[] | Literal argv arguments. |
options optional | CommandOptions | Optional working directory, environment, stdio, and limits. |
Output — Captured Output.NotFoundOnPathError— if the executable cannot be found.Error— withcode: ExecErrorCodeon invalid arguments, timeout, or output overflow.
export function run(command: Command): Promise<CommandStatus>;
export function run(argv: readonly string[], options?: CommandOptions): Promise<CommandStatus>;
export function run(program: string, options?: CommandOptions): Promise<CommandStatus>;
export function run(
program: string,
args: readonly string[],
options?: CommandOptions,
): Promise<CommandStatus>;
Execute a command asynchronously with inherited standard streams by default and return exit status metadata.
Available in vjs (vaeljs) only; use runSync in vjs-lite.
run(command)| Name | Type | Description |
|---|---|---|
command | Command | Configured Command builder. |
Promise<CommandStatus> — Promise resolving to CommandStatus.run(argv, options?)Execute an [program, ...args] argv array asynchronously with inherited standard streams by default.
| Name | Type | Description |
|---|---|---|
argv | readonly string[] | Non-empty [program, ...args] array. |
options optional | CommandOptions | Optional command configuration. |
Promise<CommandStatus> — Promise resolving to CommandStatus.run(program, options?)Execute program asynchronously with inherited standard streams by default.
| Name | Type | Description |
|---|---|---|
program | string | Executable name or path. |
options optional | CommandOptions | Optional command configuration. |
Promise<CommandStatus> — Promise resolving to CommandStatus.run(program, args, options?)Execute program with args asynchronously with inherited standard streams by default.
| Name | Type | Description |
|---|---|---|
program | string | Executable name or path. |
args | readonly string[] | Literal argv arguments. |
options optional | CommandOptions | Optional command configuration. |
Promise<CommandStatus> — Promise resolving to CommandStatus.runSync
Section titled “runSync”export function runSync(command: Command): CommandStatus;
export function runSync(argv: readonly string[], options?: CommandOptions): CommandStatus;
export function runSync(program: string, options?: CommandOptions): CommandStatus;
export function runSync(
program: string,
args: readonly string[],
options?: CommandOptions,
): CommandStatus;
Execute a command synchronously with inherited standard streams by default and return exit status metadata.
Available in both vjs (vaeljs) and vjs-lite (vaeljs-lite).
runSync(command)| Name | Type | Description |
|---|---|---|
command | Command | Configured Command builder. |
CommandStatus — CommandStatus.runSync(argv, options?)Execute an [program, ...args] argv array synchronously with inherited standard streams by default.
| Name | Type | Description |
|---|---|---|
argv | readonly string[] | Non-empty [program, ...args] array. |
options optional | CommandOptions | Optional command configuration. |
CommandStatus — CommandStatus.runSync(program, options?)Execute program synchronously with inherited standard streams by default.
| Name | Type | Description |
|---|---|---|
program | string | Executable name or path. |
options optional | CommandOptions | Optional command configuration. |
CommandStatus — CommandStatus.runSync(program, args, options?)Execute program with args synchronously with inherited standard streams by default.
| Name | Type | Description |
|---|---|---|
program | string | Executable name or path. |
args | readonly string[] | Literal argv arguments. |
options optional | CommandOptions | Optional command configuration. |
CommandStatus — CommandStatus.export function spawn(command: Command): ChildProcess;
export function spawn(argv: readonly string[], options?: CommandOptions): ChildProcess;
export function spawn(program: string, options?: CommandOptions): ChildProcess;
export function spawn(
program: string,
args: readonly string[],
options?: CommandOptions,
): ChildProcess;
Spawn a Command as a managed ChildProcess handle with piped streams by
default.
Available in vjs (vaeljs) only.
spawn(command)| Name | Type | Description |
|---|---|---|
command | Command | Configured Command builder. |
ChildProcess — Spawned ChildProcess handle.spawn(argv, options?)Spawn an [program, ...args] argv array as a managed ChildProcess handle.
| Name | Type | Description |
|---|---|---|
argv | readonly string[] | Non-empty [program, ...args] array. |
options optional | CommandOptions | Optional command configuration. |
ChildProcess — Spawned ChildProcess handle.spawn(program, options?)Spawn program as a managed ChildProcess handle.
| Name | Type | Description |
|---|---|---|
program | string | Executable name or path. |
options optional | CommandOptions | Optional command configuration. |
ChildProcess — Spawned ChildProcess handle.spawn(program, args, options?)Spawn program with args as a managed ChildProcess handle.
| Name | Type | Description |
|---|---|---|
program | string | Executable name or path. |
args | readonly string[] | Literal argv arguments. |
options optional | CommandOptions | Optional command configuration. |
ChildProcess — Spawned ChildProcess handle.export function which(
name: string,
prependPath?: string | { readonly prependPath?: string },
): Promise<string | null>;
Asynchronously find the first executable matching name on PATH
(optionally prepended by prependPath).
Available in vjs (vaeljs) only; use whichSync in vjs-lite.
| Name | Type | Description |
|---|---|---|
name | string | Bare executable name or explicit path. |
prependPath optional | string | { readonly prependPath?: string } | Optional PATH-formatted prefix searched before PATH. |
Promise<string | null> — Promise resolving to the resolved executable path, or null if not found.Error— ("VAEL_EXEC_INVALID_ARGUMENT") ifnameis empty or contains NUL bytes.
whichSync
Section titled “whichSync”export function whichSync(
name: string,
prependPath?: string | { readonly prependPath?: string },
): string | null;
Synchronously find the first executable matching name on PATH
(optionally prepended by prependPath).
Available in both vjs (vaeljs) and vjs-lite (vaeljs-lite).
| Name | Type | Description |
|---|---|---|
name | string | Bare executable name or explicit path. |
prependPath optional | string | { readonly prependPath?: string } | Optional PATH-formatted prefix or options object { prependPath? }. |
string | null — Resolved executable path, or null if not found.Error— ("VAEL_EXEC_INVALID_ARGUMENT") ifnameis empty or contains NUL bytes.
whichAll
Section titled “whichAll”export function whichAll(
name: string,
prependPath?: string | { readonly prependPath?: string },
): Promise<string[]>;
Asynchronously find all executables matching name across prependPath
and PATH in search order.
Available in vjs (vaeljs) only; use whichAllSync in vjs-lite.
| Name | Type | Description |
|---|---|---|
name | string | Bare executable name or explicit path. |
prependPath optional | string | { readonly prependPath?: string } | Optional PATH-formatted prefix or options object { prependPath? }. |
Promise<string[]> — Promise resolving to an array of matching executable paths.Error— ("VAEL_EXEC_INVALID_ARGUMENT") ifnameis empty or contains NUL bytes.
whichAllSync
Section titled “whichAllSync”export function whichAllSync(
name: string,
prependPath?: string | { readonly prependPath?: string },
): string[];
Synchronously find all executables matching name across prependPath
and PATH in search order.
Available in both vjs (vaeljs) and vjs-lite (vaeljs-lite).
| Name | Type | Description |
|---|---|---|
name | string | Bare executable name or explicit path. |
prependPath optional | string | { readonly prependPath?: string } | Optional PATH-formatted prefix or options object { prependPath? }. |
string[] — Array of matching executable paths in search order.Error— ("VAEL_EXEC_INVALID_ARGUMENT") ifnameis empty or contains NUL bytes.
lockFile
Section titled “lockFile”export function lockFile(path: string, options?: LockOptions): Promise<FileLock>;
Asynchronously acquire an OS advisory file lock on path (rejecting
symbolic links).
Available in vjs (vaeljs) only; use lockFileSync in vjs-lite.
| Name | Type | Description |
|---|---|---|
path | string | Target lock file path (must not be a symlink or end with .). |
options optional | LockOptions | Optional { mode, create, nonBlocking, timeout } settings. |
Error— withcode"VAEL_EXEC_LOCK_WOULD_BLOCK","VAEL_EXEC_LOCK_TIMEOUT","VAEL_EXEC_INVALID_ARGUMENT", or"VAEL_EXEC_IO".
lockFileSync
Section titled “lockFileSync”export function lockFileSync(path: string, options?: LockOptions): FileLock;
Synchronously acquire an OS advisory file lock on path (rejecting
symbolic links).
Available in both vjs (vaeljs) and vjs-lite (vaeljs-lite).
| Name | Type | Description |
|---|---|---|
path | string | Target lock file path (must not be a symlink or end with .). |
options optional | LockOptions | Optional { mode, create, nonBlocking, timeout } settings. |
FileLock — Active FileLock guard.Error— withcode"VAEL_EXEC_LOCK_WOULD_BLOCK","VAEL_EXEC_LOCK_TIMEOUT","VAEL_EXEC_INVALID_ARGUMENT", or"VAEL_EXEC_IO".
import { lockFileSync } from "vael:exec";
const lock = lockFileSync("./service.lock", { mode: "exclusive", nonBlocking: true });try { // critical section} finally { lock.unlock();}addLogger
Section titled “addLogger”export function addLogger(handler: CommandLogHandler): CommandLogSubscription;
Register a global command execution logging / audit handler.
| Name | Type | Description |
|---|---|---|
handler | CommandLogHandler | Callback invoked right before any command spawns. |
CommandLogSubscription — Disposable CommandLogSubscription guard.TypeError— ifhandleris not a function.
import { addLogger, execSync } from "vael:exec";
using _sub = addLogger((file, args) => console.log(file, args));execSync("echo", ["hello"]);clearLoggers
Section titled “clearLoggers”export function clearLoggers(): void;
Unregister all global command execution log handlers and mark existing subscriptions inactive.
voidClasses
Section titled “Classes”CommandError
Section titled “CommandError”export class CommandError extends Error {
override name: "CommandError";
readonly code: ExecErrorCode | string;
readonly exitCode?: number;
readonly signal?: Signal | string | null;
readonly timedOut: boolean;
readonly output?: Output;
readonly fileName?: string;
constructor(code: ExecErrorCode | string, message: string, options?: CommandErrorOptions);
}
Error thrown by Output.validate() or vael:exec operations when a
subprocess exits with a non-zero status code, signal termination, timeout,
or execution error.
constructor(code: ExecErrorCode | string, message: string, options?: CommandErrorOptions);
Construct a CommandError.
| Name | Type | Description |
|---|---|---|
code | ExecErrorCode | string | Machine-readable ExecErrorCode or custom code string. |
message | string | Human-readable error message. |
options optional | CommandErrorOptions | Optional failure metadata. |
| Property | Type | Description | Since |
|---|---|---|---|
name | "CommandError" | Error name ("CommandError"). | v0.0.0-alpha.2 |
code readonly | ExecErrorCode | string | Machine-readable error code. | v0.0.0-alpha.2 |
exitCode readonly optional | number | Exit status code from the failed subprocess, when available. | v0.0.0-alpha.2 |
signal readonly optional | Signal | string | null | Termination signal name, or null if not killed by a signal. | v0.0.0-alpha.2 |
timedOut readonly | boolean | true when the failure resulted from exceeding timeout. | v0.0.0-alpha.2 |
output readonly optional | Output | Captured Output object from the failed subprocess, when available. | v0.0.0-alpha.2 |
fileName readonly optional | string | Target executable or path associated with the error, when available. | v0.0.0-alpha.2 |
NotFoundOnPathError
Section titled “NotFoundOnPathError”export class NotFoundOnPathError extends Error {
override name: "NotFoundOnPathError";
readonly code: "VAEL_EXEC_NOT_FOUND";
readonly fileName: string;
constructor(fileName: string, message?: string);
}
Error thrown when a target executable cannot be found on PATH or at an
explicit path (code: "VAEL_EXEC_NOT_FOUND").
constructor(fileName: string, message?: string);
Construct a NotFoundOnPathError.
| Name | Type | Description |
|---|---|---|
fileName | string | Program name or path that was not found. |
message optional | string | Optional custom human-readable error message. |
| Property | Type | Description | Since |
|---|---|---|---|
name | "NotFoundOnPathError" | Error name ("NotFoundOnPathError"). | v0.0.0-alpha.2 |
code readonly | "VAEL_EXEC_NOT_FOUND" | Stable error code ("VAEL_EXEC_NOT_FOUND"). | v0.0.0-alpha.2 |
fileName readonly | string | Program name or path that failed lookup. | v0.0.0-alpha.2 |
Output
Section titled “Output”export class Output implements CommandStatus {
readonly code: number;
readonly signal: string | null;
readonly success: boolean;
readonly timedOut: boolean;
readonly truncated: boolean;
readonly stdout: Uint8Array;
readonly stderr: Uint8Array;
text(): string;
lines(): string[];
json<T = unknown>(): T;
errorText(): string;
errorLines(): string[];
errorJson<T = unknown>(): T;
validate(predicate?: (code: number) => boolean, failOnStderr?: boolean): this;
}
Captured output and termination metadata returned by exec, execSync,
and ChildProcess.waitWithOutput.
| Property | Type | Description | Since |
|---|---|---|---|
code readonly | number | Exit status code (128 + signo if terminated by signal on Unix, -1 if unavailable). | v0.0.0-alpha.2 |
signal readonly | string | null | Termination signal name (such as "SIGTERM" or "SIGKILL"), or null. | v0.0.0-alpha.2 |
success readonly | boolean | true when the subprocess exited with code 0 and did not time out. | v0.0.0-alpha.2 |
timedOut readonly | boolean | true when execution exceeded timeout and the subprocess was terminated. | v0.0.0-alpha.2 |
truncated readonly | boolean | true when captured output was truncated at a byte boundary. | v0.0.0-alpha.2 |
stdout readonly | Uint8Array | Captured standard output bytes. | v0.0.0-alpha.2 |
stderr readonly | Uint8Array | Captured standard error bytes. | v0.0.0-alpha.2 |
Output.text
Section titled “Output.text”text(): string;
Decode stdout as UTF-8 (replacing invalid sequences with U+FFFD).
string — Decoded standard output string.Output.lines
Section titled “Output.lines”lines(): string[];
Split decoded stdout into lines, stripping \n and \r\n line endings.
string[] — Array of standard output lines.Output.json
Section titled “Output.json”json<T = unknown>(): T;
Decode stdout as UTF-8 and parse it as JSON.
T — Parsed JSON value.Output.errorText
Section titled “Output.errorText”errorText(): string;
Decode stderr as UTF-8 (replacing invalid sequences with U+FFFD).
string — Decoded standard error string.Output.errorLines
Section titled “Output.errorLines”errorLines(): string[];
Split decoded stderr into lines, stripping \n and \r\n line endings.
string[] — Array of standard error lines.Output.errorJson
Section titled “Output.errorJson”errorJson<T = unknown>(): T;
Decode stderr as UTF-8 and parse it as JSON.
T — Parsed JSON value.Output.validate
Section titled “Output.validate”validate(predicate?: (code: number) => boolean, failOnStderr?: boolean): this;
Assert that the subprocess succeeded (this.success === true, or
predicate(this.code) returns true), returning this on success or
throwing CommandError on failure.
| Name | Type | Description |
|---|---|---|
predicate optional | (code: number) => boolean | Optional exit-code predicate (code: number) => boolean. |
failOnStderr optional | boolean | If true, throw CommandError ("VAEL_EXEC_STDERR") when stderr is non-empty. |
this — this when validation passes.CommandError— when validation fails.
import { execSync } from "vael:exec";
const text = execSync(["echo", "ok"]).validate().text();console.log(text);Command
Section titled “Command”export class Command {
constructor(program: string, options?: CommandOptions);
constructor(program: string, args: readonly string[], options?: CommandOptions);
constructor(argv: readonly string[], options?: CommandOptions);
arg(value: string): this;
args(values: readonly string[]): this;
cwd(path: string): this;
env(key: string, value: string): this;
envs(vars: Record<string, string | undefined>): this;
envRemove(key: string): this;
envClear(): this;
stdin(mode: StdioMode | string | Uint8Array): this;
stdout(mode: StdioMode): this;
stderr(mode: StdioMode): this;
timeout(ms: number): this;
killSignal(signal: Signal): this;
killGrace(ms: number): this;
maxOutputBytes(bytes: number): this;
toArgs(): string[];
output(): Promise<Output>;
exec(): Promise<Output>;
outputSync(): Output;
execSync(): Output;
status(): Promise<CommandStatus>;
run(): Promise<CommandStatus>;
statusSync(): CommandStatus;
runSync(): CommandStatus;
text(): Promise<string>;
lines(): Promise<string[]>;
json<T = unknown>(): Promise<T>;
log(handler: CommandLogHandler | null): this;
addLogger(handler: CommandLogHandler): CommandLogSubscription;
clearLoggers(): this;
spawn(): ChildProcess;
}
Argv-only fluent command specification builder.
Never invokes a shell; every argument, path, and environment entry is validated against NUL bytes and invalid structure before spawning.
constructor(program: string, options?: CommandOptions);
constructor(program: string, args: readonly string[], options?: CommandOptions);
constructor(argv: readonly string[], options?: CommandOptions);
Construct a Command specification for program, (program, args, options?), or (argv, options?).
new Command(program, options?)| Name | Type | Description |
|---|---|---|
program | string | Executable name/path or non-empty [program, ...args] array. |
options optional | CommandOptions | Optional command configuration when argsOrOptions is an argument array. |
new Command(program, args, options?)| Name | Type | Description |
|---|---|---|
program | string | — |
args | readonly string[] | — |
options optional | CommandOptions | — |
new Command(argv, options?)| Name | Type | Description |
|---|---|---|
argv | readonly string[] | — |
options optional | CommandOptions | — |
Error— ("VAEL_EXEC_INVALID_ARGUMENT") whenprogramis empty or contains NUL bytes.
Command.arg
Section titled “Command.arg”arg(value: string): this;
Append a single literal argument (never shell-expanded).
| Name | Type | Description |
|---|---|---|
value | string | Literal argument string (must not contain NUL bytes). |
this — this for fluent chaining.Error— ("VAEL_EXEC_INVALID_ARGUMENT") ifvaluecontains a NUL byte.
Command.args
Section titled “Command.args”args(values: readonly string[]): this;
Append multiple literal arguments in order (never shell-expanded).
| Name | Type | Description |
|---|---|---|
values | readonly string[] | Array of literal argument strings. |
this — this for fluent chaining.Error— ("VAEL_EXEC_INVALID_ARGUMENT") if any argument contains a NUL byte.
Command.cwd
Section titled “Command.cwd”cwd(path: string): this;
Set the subprocess working directory.
| Name | Type | Description |
|---|---|---|
path | string | Non-empty NUL-free directory path. |
this — this for fluent chaining.Error— ("VAEL_EXEC_INVALID_ARGUMENT") ifpathis empty or contains NUL bytes.
Command.env
Section titled “Command.env”env(key: string, value: string): this;
Set or override a single environment variable on the subprocess.
| Name | Type | Description |
|---|---|---|
key | string | Non-empty environment variable name (no '=' or NUL). |
value | string | Environment variable value (no NUL). |
this — this for fluent chaining.Error— ("VAEL_EXEC_INVALID_ARGUMENT") on invalid key or NUL-containing value.
Command.envs
Section titled “Command.envs”envs(vars: Record<string, string | undefined>): this;
Set multiple environment variables on the subprocess.
| Name | Type | Description |
|---|---|---|
vars | Record<string, string | undefined> | Plain object map (undefined values are skipped). |
this — this for fluent chaining.Error— ("VAEL_EXEC_INVALID_ARGUMENT") on invalid keys or NUL-containing values.
Command.envRemove
Section titled “Command.envRemove”envRemove(key: string): this;
Remove an inherited or previously configured environment variable.
| Name | Type | Description |
|---|---|---|
key | string | Non-empty environment variable name (no '=' or NUL). |
this — this for fluent chaining.Error— ("VAEL_EXEC_INVALID_ARGUMENT") on invalid key.
Command.envClear
Section titled “Command.envClear”envClear(): this;
Clear all inherited and previously configured environment variables.
this — this for fluent chaining.Command.stdin
Section titled “Command.stdin”stdin(mode: StdioMode | string | Uint8Array): this;
Configure standard input wiring ("inherit", "piped", "null", or
fixed bytes written before closing EOF).
| Name | Type | Description |
|---|---|---|
mode | StdioMode | string | Uint8Array | Standard input mode or byte payload. |
this — this for fluent chaining.Command.stdout
Section titled “Command.stdout”stdout(mode: StdioMode): this;
Configure standard output wiring ("inherit", "piped", or "null").
| Name | Type | Description |
|---|---|---|
mode | StdioMode | Standard output wiring mode. |
this — this for fluent chaining.Command.stderr
Section titled “Command.stderr”stderr(mode: StdioMode): this;
Configure standard error wiring ("inherit", "piped", or "null").
| Name | Type | Description |
|---|---|---|
mode | StdioMode | Standard error wiring mode. |
this — this for fluent chaining.Command.timeout
Section titled “Command.timeout”timeout(ms: number): this;
Set a finite positive execution timeout in milliseconds.
| Name | Type | Description |
|---|---|---|
ms | number | Timeout duration in milliseconds (> 0). |
this — this for fluent chaining.Error— ("VAEL_EXEC_INVALID_ARGUMENT") ifms <= 0or non-finite.
Command.killSignal
Section titled “Command.killSignal”killSignal(signal: Signal): this;
Set the initial signal sent when timeout expires (default "SIGTERM").
| Name | Type | Description |
|---|---|---|
signal | Signal | Signal name. |
this — this for fluent chaining.Command.killGrace
Section titled “Command.killGrace”killGrace(ms: number): this;
Set the grace period in milliseconds after killSignal before escalating
to "SIGKILL" (default 2_000; 0 escalates immediately).
| Name | Type | Description |
|---|---|---|
ms | number | Grace duration in milliseconds (>= 0). |
this — this for fluent chaining.Command.maxOutputBytes
Section titled “Command.maxOutputBytes”maxOutputBytes(bytes: number): this;
Set the maximum captured byte limit per output stream (default 16 MiB, hard cap 64 MiB).
| Name | Type | Description |
|---|---|---|
bytes | number | Maximum bytes per stream (0..=67_108_864). |
this — this for fluent chaining.Error— ("VAEL_EXEC_INVALID_ARGUMENT") ifbytesexceeds 64 MiB.
Command.toArgs
Section titled “Command.toArgs”toArgs(): string[];
Return the full [program, ...args] argv vector configured on this
command.
string[] — Copy of the [program, ...args] argument array.Command.output
Section titled “Command.output”output(): Promise<Output>;
Execute this command asynchronously, capturing stdout and stderr.
Available in vjs (vaeljs) only.
NotFoundOnPathError— if the executable cannot be found.Error— withcode: ExecErrorCodeon spawn, timeout, or output-limit failure.
Command.exec
Section titled “Command.exec”exec(): Promise<Output>;
Alias for output().
Available in vjs (vaeljs) only.
Command.outputSync
Section titled “Command.outputSync”outputSync(): Output;
Execute this command synchronously, capturing stdout and stderr.
Output — Captured Output.NotFoundOnPathError— if the executable cannot be found.Error— withcode: ExecErrorCodeon spawn, timeout, or output-limit failure.
Command.execSync
Section titled “Command.execSync”execSync(): Output;
Alias for outputSync().
Output — Captured Output.Command.status
Section titled “Command.status”status(): Promise<CommandStatus>;
Execute this command asynchronously with inherited standard streams by default.
Available in vjs (vaeljs) only.
Promise<CommandStatus> — Promise resolving to CommandStatus.NotFoundOnPathError— if the executable cannot be found.Error— withcode: ExecErrorCodeon spawn or timeout failure.
Command.run
Section titled “Command.run”run(): Promise<CommandStatus>;
Alias for status().
Available in vjs (vaeljs) only.
Promise<CommandStatus> — Promise resolving to CommandStatus.Command.statusSync
Section titled “Command.statusSync”statusSync(): CommandStatus;
Execute this command synchronously with inherited standard streams by default.
CommandStatus — CommandStatus.NotFoundOnPathError— if the executable cannot be found.Error— withcode: ExecErrorCodeon spawn or timeout failure.
Command.runSync
Section titled “Command.runSync”runSync(): CommandStatus;
Alias for statusSync().
CommandStatus — CommandStatus.Command.text
Section titled “Command.text”text(): Promise<string>;
Execute asynchronously, validate zero exit status, and decode stdout as UTF-8 text.
Promise<string> — Promise resolving to decoded stdout text.Command.lines
Section titled “Command.lines”lines(): Promise<string[]>;
Execute asynchronously, validate zero exit status, and split stdout into lines.
Promise<string[]> — Promise resolving to stdout lines.Command.json
Section titled “Command.json”json<T = unknown>(): Promise<T>;
Execute asynchronously, validate zero exit status, and parse stdout as JSON.
Promise<T> — Promise resolving to parsed JSON value.Command.log
Section titled “Command.log”log(handler: CommandLogHandler | null): this;
Set or clear (null) the single per-instance log hook on this command.
| Name | Type | Description |
|---|---|---|
handler | CommandLogHandler | null | Pre-spawn hook or null to clear. |
this — this for fluent chaining.TypeError— ifhandleris neither a function nornull.
Command.addLogger
Section titled “Command.addLogger”addLogger(handler: CommandLogHandler): CommandLogSubscription;
Attach a disposable per-instance log/audit handler to this command.
| Name | Type | Description |
|---|---|---|
handler | CommandLogHandler | Pre-spawn log/audit callback. |
CommandLogSubscription — Frozen CommandLogSubscription handle.TypeError— ifhandleris not a function.
Command.clearLoggers
Section titled “Command.clearLoggers”clearLoggers(): this;
Clear the per-instance log hook and all addLogger subscriptions on
this command, marking existing subscriptions inactive.
this — this for fluent chaining.Command.spawn
Section titled “Command.spawn”spawn(): ChildProcess;
Spawn this command as a managed ChildProcess handle with piped streams.
Available in vjs (vaeljs) only.
ChildProcess — Spawned ChildProcess handle.NotFoundOnPathError— if the executable cannot be found.Error— withcode: ExecErrorCodeon spawn failure.
ChildProcess
Section titled “ChildProcess”export class ChildProcess {
readonly pid: number;
writeStdin(data: string | Uint8Array): Promise<void>;
closeStdin(): void;
readStdout(maxBytes?: number): Promise<Uint8Array>;
readStderr(maxBytes?: number): Promise<Uint8Array>;
kill(signal?: Signal): void;
tryWait(): CommandStatus | null;
wait(): Promise<CommandStatus>;
waitWithOutput(options?: {
/** Maximum bytes captured per output stream. @since 0.0.0-alpha.2 */
maxOutputBytes?: number;
/** Finite timeout in milliseconds. @since 0.0.0-alpha.2 */
timeout?: number;
/** Alias for `timeout` in milliseconds. @since 0.0.0-alpha.2 */
timeoutMs?: number;
}): Promise<Output>;
output(): Promise<Output>;
[Symbol.asyncDispose](): Promise<void>;
}
Managed streaming subprocess handle returned by spawn.
Available in the vjs (vaeljs) runtime only; absent in vjs-lite.
| Property | Type | Description | Since |
|---|---|---|---|
pid readonly | number | OS-assigned identifier for the spawned subprocess. | v0.0.0-alpha.2 |
ChildProcess.writeStdin
Section titled “ChildProcess.writeStdin”writeStdin(data: string | Uint8Array): Promise<void>;
Write UTF-8 text or raw bytes to the subprocess’s piped stdin and flush.
| Name | Type | Description |
|---|---|---|
data | string | Uint8Array | Text or bytes to write to stdin. |
Promise<void> — Promise resolving when the write and flush complete.Error— ("VAEL_EXEC_INVALID_ARGUMENT"or"VAEL_EXEC_IO") ifstdinis not piped or closed.
ChildProcess.closeStdin
Section titled “ChildProcess.closeStdin”closeStdin(): void;
Close the parent’s handle to stdin (sending EOF to the subprocess).
voidChildProcess.readStdout
Section titled “ChildProcess.readStdout”readStdout(maxBytes?: number): Promise<Uint8Array>;
Read up to maxBytes currently available bytes from piped stdout.
Returns an empty Uint8Array on EOF.
| Name | Type | Description |
|---|---|---|
maxBytes optional | number | Maximum bytes to read (capped at 64 MiB). |
Promise<Uint8Array> — Promise resolving to the read chunk (Uint8Array).Error— ("VAEL_EXEC_INVALID_ARGUMENT"or"VAEL_EXEC_IO") ifstdoutis not piped.
ChildProcess.readStderr
Section titled “ChildProcess.readStderr”readStderr(maxBytes?: number): Promise<Uint8Array>;
Read up to maxBytes currently available bytes from piped stderr.
Returns an empty Uint8Array on EOF.
| Name | Type | Description |
|---|---|---|
maxBytes optional | number | Maximum bytes to read (capped at 64 MiB). |
Promise<Uint8Array> — Promise resolving to the read chunk (Uint8Array).Error— ("VAEL_EXEC_INVALID_ARGUMENT"or"VAEL_EXEC_IO") ifstderris not piped.
ChildProcess.kill
Section titled “ChildProcess.kill”kill(signal?: Signal): void;
Send a termination/control signal to the subprocess (defaults to "SIGTERM").
No-ops if the subprocess has already exited and been reaped.
| Name | Type | Description |
|---|---|---|
signal optional | Signal | Signal to send ("SIGTERM", "SIGKILL", etc.). |
voidError— ("VAEL_EXEC_UNSUPPORTED_SIGNAL"or"VAEL_EXEC_IO") if signaling fails.
ChildProcess.tryWait
Section titled “ChildProcess.tryWait”tryWait(): CommandStatus | null;
Non-blocking poll checking whether the subprocess has exited.
ChildProcess.wait
Section titled “ChildProcess.wait”wait(): Promise<CommandStatus>;
Wait for the subprocess to exit and reap it.
Promise<CommandStatus> — Promise resolving to CommandStatus.ChildProcess.waitWithOutput
Section titled “ChildProcess.waitWithOutput”waitWithOutput(options?: {
/** Maximum bytes captured per output stream. @since 0.0.0-alpha.2 */
maxOutputBytes?: number;
/** Finite timeout in milliseconds. @since 0.0.0-alpha.2 */
timeout?: number;
/** Alias for `timeout` in milliseconds. @since 0.0.0-alpha.2 */
timeoutMs?: number;
}): Promise<Output>;
Close any remaining stdin, concurrently drain stdout and stderr,
and wait for exit (enforcing optional timeout and maxOutputBytes).
| Name | Type | Description |
|---|---|---|
options optional | {
/** Maximum bytes captured per output stream. @since 0.0.0-alpha.2 */
maxOutputBytes?: number;
/** Finite timeout in milliseconds. @since 0.0.0-alpha.2 */
timeout?: number;
/** Alias for `timeout` in milliseconds. @since 0.0.0-alpha.2 */
timeoutMs?: number;
} | Optional { maxOutputBytes, timeout } bounds. |
ChildProcess.output
Section titled “ChildProcess.output”output(): Promise<Output>;
Alias for waitWithOutput().
ChildProcess.[Symbol.asyncDispose]
Section titled “ChildProcess.[Symbol.asyncDispose]”[Symbol.asyncDispose](): Promise<void>;
Dispose the child handle when leaving an await using block by sending
"SIGTERM" if still running and waiting for exit.
Promise<void> — Promise resolving once the subprocess has been reaped.FileLock
Section titled “FileLock”export class FileLock {
readonly path: string;
readonly mode: LockMode;
readonly locked: boolean;
unlock(): void;
[Symbol.dispose](): void;
[Symbol.asyncDispose](): Promise<void>;
}
Active OS advisory file lock guard returned by lockFile and lockFileSync.
Releases the underlying lock when unlock() is called or when disposed via
using ([Symbol.dispose]()).
| Property | Type | Description | Since |
|---|---|---|---|
path readonly | string | Target lock file path associated with this guard. | v0.0.0-alpha.2 |
mode readonly | LockMode | Lock sharing mode held by this guard ("shared" or "exclusive"). | v0.0.0-alpha.2 |
locked readonly | boolean | true while the advisory OS lock is currently held by this guard. | v0.0.0-alpha.2 |
FileLock.unlock
Section titled “FileLock.unlock”unlock(): void;
Explicitly unlock and close the underlying file handle. Idempotent on subsequent calls after release.
voidError— ("VAEL_EXEC_IO") if the OS unlock operation fails.
FileLock.[Symbol.dispose]
Section titled “FileLock.[Symbol.dispose]”[Symbol.dispose](): void;
Release the advisory file lock when exiting a using scope.
voidFileLock.[Symbol.asyncDispose]
Section titled “FileLock.[Symbol.asyncDispose]”[Symbol.asyncDispose](): Promise<void>;
Release the advisory file lock when exiting an await using scope.
Promise<void> — Promise resolving after unlocking.PathFinder
Section titled “PathFinder”export class PathFinder {
set(name: string, options: PathFinderOptions): this;
get(name: string): PathFinderOptions | undefined;
has(name: string): boolean;
delete(name: string): boolean;
clear(): void;
find(name: string): PathFinderOptions | undefined;
findExeSync(name: string): string | undefined;
findExe(name: string): Promise<string | undefined>;
}
Executable registry for resolving and caching platform binary paths.
PathFinder.set
Section titled “PathFinder.set”set(name: string, options: PathFinderOptions): this;
Register or update executable lookup configuration under name.
| Name | Type | Description |
|---|---|---|
name | string | Registry key name. |
options | PathFinderOptions | Validated PathFinderOptions configuration. |
this — this for chaining.TypeError— ifnameoroptionsis invalid.
PathFinder.get
Section titled “PathFinder.get”get(name: string): PathFinderOptions | undefined;
Retrieve a shallow clone of the entry registered under exact key name.
| Name | Type | Description |
|---|---|---|
name | string | Registry key name. |
PathFinder.has
Section titled “PathFinder.has”has(name: string): boolean;
Return true if exact key name is registered.
| Name | Type | Description |
|---|---|---|
name | string | Registry key name. |
booleanPathFinder.delete
Section titled “PathFinder.delete”delete(name: string): boolean;
Delete exact key name from the registry.
| Name | Type | Description |
|---|---|---|
name | string | Registry key name. |
boolean — true if an entry was removed.PathFinder.clear
Section titled “PathFinder.clear”clear(): void;
Remove all entries from the registry.
voidPathFinder.find
Section titled “PathFinder.find”find(name: string): PathFinderOptions | undefined;
Find a registered entry by exact key, options.name, options.cached,
or ASCII case-insensitive match.
| Name | Type | Description |
|---|---|---|
name | string | Executable key, name, or cached path. |
PathFinder.findExeSync
Section titled “PathFinder.findExeSync”findExeSync(name: string): string | undefined;
Synchronously resolve name to an executable file path via env
overrides, cache, PATH, and platform fallback candidates.
| Name | Type | Description |
|---|---|---|
name | string | Executable key or name. |
string | undefined — Resolved executable path, or undefined if not found.PathFinder.findExe
Section titled “PathFinder.findExe”findExe(name: string): Promise<string | undefined>;
Asynchronously resolve name to an executable file path via env
overrides, cache, PATH, and platform fallback candidates.
Available in vjs (vaeljs) only; use findExeSync in vjs-lite.
| Name | Type | Description |
|---|---|---|
name | string | Executable key or name. |
Promise<string | undefined> — Promise resolving to the executable path, or undefined.Interfaces
Section titled “Interfaces”CommandOptions
Section titled “CommandOptions”export interface CommandOptions {
args?: readonly string[];
cwd?: string;
env?: Record<string, string | undefined>;
envRemove?: readonly string[];
clearEnv?: boolean;
stdin?: StdioMode | string | Uint8Array;
stdout?: StdioMode;
stderr?: StdioMode;
timeout?: number;
timeoutMs?: number;
killSignal?: Signal;
killGrace?: number;
killGraceMs?: number;
maxOutputBytes?: number;
log?: CommandLogHandler;
}
Options accepted by Command, cmd, exec, execSync, run, runSync,
and spawn.
| Property | Type | Description | Since |
|---|---|---|---|
args optional | readonly string[] | Additional literal argv arguments appended after any arguments passed in the command invocation (never shell-expanded). | v0.0.0-alpha.2 |
cwd optional | string | Working directory for the subprocess (inherits parent cwd when omitted). | v0.0.0-alpha.2 |
env optional | Record<string, string | undefined> | Environment variables set on the subprocess (undefined entries are omitted or removed). | v0.0.0-alpha.2 |
envRemove optional | readonly string[] | Environment variable names to remove from the subprocess environment. | v0.0.0-alpha.2 |
clearEnv optional | boolean | Clear all inherited environment variables before applying env (default false). | v0.0.0-alpha.2 |
stdin optional | StdioMode | string | Uint8Array | Standard input configuration: "inherit", "piped", "null", or fixed bytes (string or Uint8Array) written to stdin and closed at EOF. | v0.0.0-alpha.2 |
stdout optional | StdioMode | Standard output wiring mode ("inherit", "piped", or "null"). | v0.0.0-alpha.2 |
stderr optional | StdioMode | Standard error wiring mode ("inherit", "piped", or "null"). | v0.0.0-alpha.2 |
timeout optional | number | Finite positive execution timeout in milliseconds. On expiry, sends killSignal and escalates to "SIGKILL" after killGrace / killGraceMs. | v0.0.0-alpha.2 |
timeoutMs optional | number | Alias for timeout (mutually exclusive with timeout). | v0.0.0-alpha.2 |
killSignal optional | Signal | Initial termination signal sent when timeout expires (default "SIGTERM"). | v0.0.0-alpha.2 |
killGrace optional | number | Grace period in milliseconds after killSignal before escalating to "SIGKILL" (default 2_000; 0 escalates immediately). | v0.0.0-alpha.2 |
killGraceMs optional | number | Alias for killGrace (mutually exclusive with killGrace). | v0.0.0-alpha.2 |
maxOutputBytes optional | number | Maximum bytes captured per output stream (stdout and stderr, default 16_777_216 / 16 MiB, hard cap 67_108_864 / 64 MiB). | v0.0.0-alpha.2 |
log optional | CommandLogHandler | Optional per-instance execution logging / audit hook invoked right before spawning the command. Throwing from this hook aborts spawn. | v0.0.0-alpha.2 |
CommandLogEvent
Section titled “CommandLogEvent”export interface CommandLogEvent {
readonly file: string;
readonly args: readonly string[];
readonly cwd?: string;
readonly mode: "exec" | "execSync" | "run" | "runSync" | "spawn";
}
Event metadata passed to a CommandLogHandler before a subprocess spawns.
| Property | Type | Description | Since |
|---|---|---|---|
file readonly | string | Resolved executable name or path about to be executed. | v0.0.0-alpha.2 |
args readonly | readonly string[] | Frozen snapshot of argument strings passed to the executable (excluding argv[0]). | v0.0.0-alpha.2 |
cwd readonly optional | string | Configured working directory for the command, if explicitly set. | v0.0.0-alpha.2 |
mode readonly | "exec" | "execSync" | "run" | "runSync" | "spawn" | Execution entry point mode that triggered the spawn. | v0.0.0-alpha.2 |
CommandLogSubscription
Section titled “CommandLogSubscription”export interface CommandLogSubscription {
readonly active: boolean;
dispose(): void;
[Symbol.dispose](): void;
}
Disposable handle returned by addLogger and Command.addLogger.
Calling dispose() or exiting a using block removes only this
subscription idempotently and flips active to false.
| Property | Type | Description | Since |
|---|---|---|---|
active readonly | boolean | true while the handler subscription remains registered and active. | v0.0.0-alpha.2 |
CommandLogSubscription.dispose
Section titled “CommandLogSubscription.dispose”dispose(): void;
Unregister this specific log handler subscription idempotently.
voidCommandLogSubscription.[Symbol.dispose]
Section titled “CommandLogSubscription.[Symbol.dispose]”[Symbol.dispose](): void;
Dispose this subscription automatically when exiting a using block.
voidPathFinderOptions
Section titled “PathFinderOptions”export interface PathFinderOptions {
name: string;
executable?: string;
envVariable?: string;
cached?: string;
noCache?: boolean;
windows?: readonly string[];
linux?: readonly string[];
darwin?: readonly string[];
}
Executable lookup entry stored in a PathFinder registry.
| Property | Type | Description | Since |
|---|---|---|---|
name | string | Canonical executable name for this entry. | v0.0.0-alpha.2 |
executable optional | string | Executable binary name or explicit path to look up instead of name. | v0.0.0-alpha.2 |
envVariable optional | string | Environment variable name checked for an explicit executable path override. | v0.0.0-alpha.2 |
cached optional | string | Cached resolved path returned when noCache is not true. | v0.0.0-alpha.2 |
noCache optional | boolean | Disable caching resolved paths on this entry when true. | v0.0.0-alpha.2 |
windows optional | readonly string[] | Ordered candidate fallback paths on Windows (supports ${VAR} and %VAR% expansion). | v0.0.0-alpha.2 |
linux optional | readonly string[] | Ordered candidate fallback paths on Linux (supports ${VAR} and %VAR% expansion). | v0.0.0-alpha.2 |
darwin optional | readonly string[] | Ordered candidate fallback paths on macOS (darwin; supports ${VAR} and %VAR% expansion). | v0.0.0-alpha.2 |
CommandStatus
Section titled “CommandStatus”export interface CommandStatus {
readonly code: number;
readonly signal: string | null;
readonly success: boolean;
readonly timedOut: boolean;
}
Subprocess exit status metadata returned by run, runSync,
ChildProcess.tryWait, and ChildProcess.wait.
| Property | Type | Description | Since |
|---|---|---|---|
code readonly | number | Exit status code (128 + signo if killed by a signal on Unix, -1 if unavailable). | v0.0.0-alpha.2 |
signal readonly | string | null | Termination signal name (for example "SIGTERM" or "SIGKILL"), or null when the subprocess exited normally. | v0.0.0-alpha.2 |
success readonly | boolean | true when the subprocess exited with status 0 and did not time out. | v0.0.0-alpha.2 |
timedOut readonly | boolean | true when execution exceeded timeout and the subprocess was terminated. | v0.0.0-alpha.2 |
LockOptions
Section titled “LockOptions”export interface LockOptions {
mode?: LockMode;
create?: boolean;
nonBlocking?: boolean;
timeout?: number;
}
Options accepted by lockFile and lockFileSync.
nonBlocking: true and timeout are mutually exclusive and throw with
"VAEL_EXEC_INVALID_ARGUMENT" if combined.
| Property | Type | Description | Since |
|---|---|---|---|
mode optional | LockMode | Advisory lock sharing mode (default "exclusive"). | v0.0.0-alpha.2 |
create optional | boolean | Create the target lock file if it does not already exist (default true). | v0.0.0-alpha.2 |
nonBlocking optional | boolean | Fail immediately with "VAEL_EXEC_LOCK_WOULD_BLOCK" if a conflicting lock is held (default false). | v0.0.0-alpha.2 |
timeout optional | number | Optional bounded wait duration in milliseconds before failing with "VAEL_EXEC_LOCK_TIMEOUT". | v0.0.0-alpha.2 |
CommandErrorOptions
Section titled “CommandErrorOptions”export interface CommandErrorOptions {
readonly exitCode?: number;
readonly signal?: Signal | string | null;
readonly timedOut?: boolean;
readonly output?: Output;
readonly fileName?: string;
}
Optional metadata attached to a CommandError.
| Property | Type | Description | Since |
|---|---|---|---|
exitCode readonly optional | number | Exit status code from the failed subprocess. | v0.0.0-alpha.2 |
signal readonly optional | Signal | string | null | Termination signal name, or null. | v0.0.0-alpha.2 |
timedOut readonly optional | boolean | Whether the failure resulted from exceeding timeout. | v0.0.0-alpha.2 |
output readonly optional | Output | Captured Output from the failed command, when available. | v0.0.0-alpha.2 |
fileName readonly optional | string | Target executable name/path, when applicable. | v0.0.0-alpha.2 |
Type Aliases
Section titled “Type Aliases”ExecErrorCode
Section titled “ExecErrorCode”export type ExecErrorCode =
| "VAEL_EXEC_NOT_FOUND"
| "VAEL_EXEC_PERMISSION_DENIED"
| "VAEL_EXEC_INVALID_ARGUMENT"
| "VAEL_EXEC_TIMEOUT"
| "VAEL_EXEC_OUTPUT_TOO_LARGE"
| "VAEL_EXEC_UNSUPPORTED_SIGNAL"
| "VAEL_EXEC_LOCK_WOULD_BLOCK"
| "VAEL_EXEC_LOCK_TIMEOUT"
| "VAEL_EXEC_NON_ZERO"
| "VAEL_EXEC_STDERR"
| "VAEL_EXEC_IO";
Stable machine-readable VAEL_EXEC_* error codes exposed on Error.code
by vael:exec operations.
StdioMode
Section titled “StdioMode”export type StdioMode = "inherit" | "piped" | "null";
Standard stream wiring mode for subprocess stdin, stdout, and stderr.
"inherit": inherit the parent descriptor"piped": connect an OS pipe"null": redirect to/dev/nullorNUL
Signal
Section titled “Signal”export type Signal =
| "SIGINT"
| "SIGTERM"
| "SIGKILL"
| "SIGHUP"
| "SIGQUIT"
| "SIGUSR1"
| "SIGUSR2";
Explicit subprocess termination or control signal.
LockMode
Section titled “LockMode”export type LockMode = "shared" | "exclusive";
Advisory file lock sharing mode.
"shared": concurrent shared reader lock"exclusive": exclusive writer lock blocking other shared and exclusive locks
CommandLogHandler
Section titled “CommandLogHandler”export type CommandLogHandler = (
file: string,
args: readonly string[],
event: CommandLogEvent,
) => void;
Pre-spawn command logging or audit callback.
Throwing an error aborts execution before spawning the subprocess.
Constants
Section titled “Constants”pathFinder
Section titled “pathFinder”export const pathFinder: PathFinder;
Default singleton PathFinder registry consulted automatically when
executing a Command whose program matches a registered entry.
