Skip to content
VaelJS Blog

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"
Since v0.0.0-alpha.2 vjs (V8) vjs-lite (QuickJS)
Cargo feature: vael-exec (enabled by default in vaeljs-core and vaeljs-lite-core)
Async and streaming APIs (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.
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);
API Symbols
Functions (14)
cmdv0.0.0-alpha.2
Create a fluent Command builder without executing it.
execvjs onlyv0.0.0-alpha.2
Execute a command asynchronously and capture stdout and stderr (defaulting stdin to "null" and stdout/stderr to "piped").
execSyncv0.0.0-alpha.2
Execute a command synchronously and capture stdout and stderr (defaulting stdin to "null" and stdout/stderr to "piped").
runvjs onlyv0.0.0-alpha.2
Execute a command asynchronously with inherited standard streams by default and return exit status metadata.
runSyncv0.0.0-alpha.2
Execute a command synchronously with inherited standard streams by default and return exit status metadata.
spawnvjs onlyv0.0.0-alpha.2
Spawn a Command as a managed ChildProcess handle with piped streams by default.
whichvjs onlyv0.0.0-alpha.2
Asynchronously find the first executable matching name on PATH (optionally prepended by prependPath).
whichSyncv0.0.0-alpha.2
Synchronously find the first executable matching name on PATH (optionally prepended by prependPath).
whichAllvjs onlyv0.0.0-alpha.2
Asynchronously find all executables matching name across prependPath and PATH in search order.
whichAllSyncv0.0.0-alpha.2
Synchronously find all executables matching name across prependPath and PATH in search order.
lockFilevjs onlyv0.0.0-alpha.2
Asynchronously acquire an OS advisory file lock on path (rejecting symbolic links).
lockFileSyncv0.0.0-alpha.2
Synchronously acquire an OS advisory file lock on path (rejecting symbolic links).
addLoggerv0.0.0-alpha.2
Register a global command execution logging / audit handler.
clearLoggersv0.0.0-alpha.2
Unregister all global command execution log handlers and mark existing subscriptions inactive.
functionSince v0.0.0-alpha.2vjs & vjs-lite
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.

Overload 1 — cmd(program, options?)
NameTypeDescription
programstringExecutable name/path or [program, ...args] array.
options optionalCommandOptionsOptional command configuration when argsOrOptions is an argument array.
Command — Configured Command builder.
Overload 2 — cmd(program, args, options?)
NameTypeDescription
programstring—
argsreadonly string[]—
options optionalCommandOptions—
Overload 3 — cmd(argv, options?)
NameTypeDescription
argvreadonly string[]—
options optionalCommandOptions—
Exceptions
  • Error — ("VAEL_EXEC_INVALID_ARGUMENT") if program is empty or contains NUL bytes.
import { cmd, execSync } from "vael:exec";
const command = cmd("env").envClear().env("FOO", "bar");
console.log(command.toArgs());
functionSince v0.0.0-alpha.2vjs only
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.

Overload 1 — exec(command)
NameTypeDescription
commandCommandConfigured Command builder.
Promise<Output> — Promise resolving to captured Output.
Overload 2 — exec(argv, options?)

Execute an [program, ...args] argv array asynchronously and capture stdout and stderr.

NameTypeDescription
argvreadonly string[]Non-empty [program, ...args] array (never shell-expanded).
options optionalCommandOptionsOptional working directory, environment, stdio, and limits.
Promise<Output> — Promise resolving to captured Output.
Overload 3 — exec(program, options?)

Execute program asynchronously with optional CommandOptions.

NameTypeDescription
programstringExecutable name or path.
options optionalCommandOptionsOptional arguments, working directory, environment, stdio, and limits.
Promise<Output> — Promise resolving to captured Output.
Overload 4 — exec(program, args, options?)

Execute program with args asynchronously and capture stdout and stderr.

NameTypeDescription
programstringExecutable name or path.
argsreadonly string[]Literal argv arguments.
options optionalCommandOptionsOptional working directory, environment, stdio, and limits.
Promise<Output> — Promise resolving to captured Output.
Exceptions
  • NotFoundOnPathError — if the executable cannot be found.
  • Error — with code: ExecErrorCode on invalid arguments, timeout, or output overflow.
functionSince v0.0.0-alpha.2vjs & vjs-lite
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).

Overload 1 — execSync(command)
NameTypeDescription
commandCommandConfigured Command builder.
Output — Captured Output.
Overload 2 — execSync(argv, options?)

Execute an [program, ...args] argv array synchronously and capture stdout and stderr.

NameTypeDescription
argvreadonly string[]Non-empty [program, ...args] array (never shell-expanded).
options optionalCommandOptionsOptional working directory, environment, stdio, and limits.
Output — Captured Output.
Overload 3 — execSync(program, options?)

Execute program synchronously with optional CommandOptions.

NameTypeDescription
programstringExecutable name or path.
options optionalCommandOptionsOptional arguments, working directory, environment, stdio, and limits.
Output — Captured Output.
Overload 4 — execSync(program, args, options?)

Execute program with args synchronously and capture stdout and stderr.

NameTypeDescription
programstringExecutable name or path.
argsreadonly string[]Literal argv arguments.
options optionalCommandOptionsOptional working directory, environment, stdio, and limits.
Output — Captured Output.
Exceptions
  • NotFoundOnPathError — if the executable cannot be found.
  • Error — with code: ExecErrorCode on invalid arguments, timeout, or output overflow.
functionSince v0.0.0-alpha.2vjs only
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.

Overload 1 — run(command)
NameTypeDescription
commandCommandConfigured Command builder.
Promise<CommandStatus> — Promise resolving to CommandStatus.
Overload 2 — run(argv, options?)

Execute an [program, ...args] argv array asynchronously with inherited standard streams by default.

NameTypeDescription
argvreadonly string[]Non-empty [program, ...args] array.
options optionalCommandOptionsOptional command configuration.
Promise<CommandStatus> — Promise resolving to CommandStatus.
Overload 3 — run(program, options?)

Execute program asynchronously with inherited standard streams by default.

NameTypeDescription
programstringExecutable name or path.
options optionalCommandOptionsOptional command configuration.
Promise<CommandStatus> — Promise resolving to CommandStatus.
Overload 4 — run(program, args, options?)

Execute program with args asynchronously with inherited standard streams by default.

NameTypeDescription
programstringExecutable name or path.
argsreadonly string[]Literal argv arguments.
options optionalCommandOptionsOptional command configuration.
Promise<CommandStatus> — Promise resolving to CommandStatus.
functionSince v0.0.0-alpha.2vjs & vjs-lite
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).

Overload 1 — runSync(command)
NameTypeDescription
commandCommandConfigured Command builder.
CommandStatus — CommandStatus.
Overload 2 — runSync(argv, options?)

Execute an [program, ...args] argv array synchronously with inherited standard streams by default.

NameTypeDescription
argvreadonly string[]Non-empty [program, ...args] array.
options optionalCommandOptionsOptional command configuration.
CommandStatus — CommandStatus.
Overload 3 — runSync(program, options?)

Execute program synchronously with inherited standard streams by default.

NameTypeDescription
programstringExecutable name or path.
options optionalCommandOptionsOptional command configuration.
CommandStatus — CommandStatus.
Overload 4 — runSync(program, args, options?)

Execute program with args synchronously with inherited standard streams by default.

NameTypeDescription
programstringExecutable name or path.
argsreadonly string[]Literal argv arguments.
options optionalCommandOptionsOptional command configuration.
CommandStatus — CommandStatus.
functionSince v0.0.0-alpha.2vjs only
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.

Overload 1 — spawn(command)
NameTypeDescription
commandCommandConfigured Command builder.
ChildProcess — Spawned ChildProcess handle.
Overload 2 — spawn(argv, options?)

Spawn an [program, ...args] argv array as a managed ChildProcess handle.

NameTypeDescription
argvreadonly string[]Non-empty [program, ...args] array.
options optionalCommandOptionsOptional command configuration.
ChildProcess — Spawned ChildProcess handle.
Overload 3 — spawn(program, options?)

Spawn program as a managed ChildProcess handle.

NameTypeDescription
programstringExecutable name or path.
options optionalCommandOptionsOptional command configuration.
ChildProcess — Spawned ChildProcess handle.
Overload 4 — spawn(program, args, options?)

Spawn program with args as a managed ChildProcess handle.

NameTypeDescription
programstringExecutable name or path.
argsreadonly string[]Literal argv arguments.
options optionalCommandOptionsOptional command configuration.
ChildProcess — Spawned ChildProcess handle.
functionSince v0.0.0-alpha.2vjs only
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.

Parameters
NameTypeDescription
namestringBare executable name or explicit path.
prependPath optionalstring | { readonly prependPath?: string }Optional PATH-formatted prefix searched before PATH.
Returns
Promise<string | null> — Promise resolving to the resolved executable path, or null if not found.
Exceptions
  • Error — ("VAEL_EXEC_INVALID_ARGUMENT") if name is empty or contains NUL bytes.
functionSince v0.0.0-alpha.2vjs & vjs-lite
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).

Parameters
NameTypeDescription
namestringBare executable name or explicit path.
prependPath optionalstring | { readonly prependPath?: string }Optional PATH-formatted prefix or options object { prependPath? }.
Returns
string | null — Resolved executable path, or null if not found.
Exceptions
  • Error — ("VAEL_EXEC_INVALID_ARGUMENT") if name is empty or contains NUL bytes.
functionSince v0.0.0-alpha.2vjs only
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.

Parameters
NameTypeDescription
namestringBare executable name or explicit path.
prependPath optionalstring | { readonly prependPath?: string }Optional PATH-formatted prefix or options object { prependPath? }.
Returns
Promise<string[]> — Promise resolving to an array of matching executable paths.
Exceptions
  • Error — ("VAEL_EXEC_INVALID_ARGUMENT") if name is empty or contains NUL bytes.
functionSince v0.0.0-alpha.2vjs & vjs-lite
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).

Parameters
NameTypeDescription
namestringBare executable name or explicit path.
prependPath optionalstring | { readonly prependPath?: string }Optional PATH-formatted prefix or options object { prependPath? }.
Returns
string[] — Array of matching executable paths in search order.
Exceptions
  • Error — ("VAEL_EXEC_INVALID_ARGUMENT") if name is empty or contains NUL bytes.
functionSince v0.0.0-alpha.2vjs only
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.

Parameters
NameTypeDescription
pathstringTarget lock file path (must not be a symlink or end with .).
options optionalLockOptionsOptional { mode, create, nonBlocking, timeout } settings.
Returns
Promise<FileLock> — Promise resolving to an active FileLock guard.
Exceptions
  • Error — with code "VAEL_EXEC_LOCK_WOULD_BLOCK", "VAEL_EXEC_LOCK_TIMEOUT", "VAEL_EXEC_INVALID_ARGUMENT", or "VAEL_EXEC_IO".
functionSince v0.0.0-alpha.2vjs & vjs-lite
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).

Parameters
NameTypeDescription
pathstringTarget lock file path (must not be a symlink or end with .).
options optionalLockOptionsOptional { mode, create, nonBlocking, timeout } settings.
Returns
FileLock — Active FileLock guard.
Exceptions
  • Error — with code "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();
}
functionSince v0.0.0-alpha.2vjs & vjs-lite
export function addLogger(handler: CommandLogHandler): CommandLogSubscription;

Register a global command execution logging / audit handler.

Parameters
NameTypeDescription
handlerCommandLogHandlerCallback invoked right before any command spawns.
Returns
CommandLogSubscription — Disposable CommandLogSubscription guard.
Exceptions
  • TypeError — if handler is not a function.
import { addLogger, execSync } from "vael:exec";
using _sub = addLogger((file, args) => console.log(file, args));
execSync("echo", ["hello"]);
functionSince v0.0.0-alpha.2vjs & vjs-lite
export function clearLoggers(): void;

Unregister all global command execution log handlers and mark existing subscriptions inactive.

Returns
void
classSince v0.0.0-alpha.2vjs & vjs-lite
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
constructor(code: ExecErrorCode | string, message: string, options?: CommandErrorOptions);

Construct a CommandError.

Parameters
NameTypeDescription
codeExecErrorCode | stringMachine-readable ExecErrorCode or custom code string.
messagestringHuman-readable error message.
options optionalCommandErrorOptionsOptional failure metadata.
Properties
PropertyTypeDescriptionSince
name "CommandError"Error name ("CommandError").v0.0.0-alpha.2
code readonlyExecErrorCode | stringMachine-readable error code.v0.0.0-alpha.2
exitCode readonly optionalnumberExit status code from the failed subprocess, when available.v0.0.0-alpha.2
signal readonly optionalSignal | string | nullTermination signal name, or null if not killed by a signal.v0.0.0-alpha.2
timedOut readonlybooleantrue when the failure resulted from exceeding timeout.v0.0.0-alpha.2
output readonly optionalOutputCaptured Output object from the failed subprocess, when available.v0.0.0-alpha.2
fileName readonly optionalstringTarget executable or path associated with the error, when available.v0.0.0-alpha.2
classSince v0.0.0-alpha.2vjs & vjs-lite
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
constructor(fileName: string, message?: string);

Construct a NotFoundOnPathError.

Parameters
NameTypeDescription
fileNamestringProgram name or path that was not found.
message optionalstringOptional custom human-readable error message.
Properties
PropertyTypeDescriptionSince
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 readonlystringProgram name or path that failed lookup.v0.0.0-alpha.2
classSince v0.0.0-alpha.2vjs & vjs-lite
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.

Properties
PropertyTypeDescriptionSince
code readonlynumberExit status code (128 + signo if terminated by signal on Unix, -1 if unavailable).v0.0.0-alpha.2
signal readonlystring | nullTermination signal name (such as "SIGTERM" or "SIGKILL"), or null.v0.0.0-alpha.2
success readonlybooleantrue when the subprocess exited with code 0 and did not time out.v0.0.0-alpha.2
timedOut readonlybooleantrue when execution exceeded timeout and the subprocess was terminated.v0.0.0-alpha.2
truncated readonlybooleantrue when captured output was truncated at a byte boundary.v0.0.0-alpha.2
stdout readonlyUint8ArrayCaptured standard output bytes.v0.0.0-alpha.2
stderr readonlyUint8ArrayCaptured standard error bytes.v0.0.0-alpha.2
Methods
methodSince v0.0.0-alpha.2
text(): string;

Decode stdout as UTF-8 (replacing invalid sequences with U+FFFD).

Returns
string — Decoded standard output string.
methodSince v0.0.0-alpha.2
lines(): string[];

Split decoded stdout into lines, stripping \n and \r\n line endings.

Returns
string[] — Array of standard output lines.
methodSince v0.0.0-alpha.2
json<T = unknown>(): T;

Decode stdout as UTF-8 and parse it as JSON.

Returns
T — Parsed JSON value.
methodSince v0.0.0-alpha.2
errorText(): string;

Decode stderr as UTF-8 (replacing invalid sequences with U+FFFD).

Returns
string — Decoded standard error string.
methodSince v0.0.0-alpha.2
errorLines(): string[];

Split decoded stderr into lines, stripping \n and \r\n line endings.

Returns
string[] — Array of standard error lines.
methodSince v0.0.0-alpha.2
errorJson<T = unknown>(): T;

Decode stderr as UTF-8 and parse it as JSON.

Returns
T — Parsed JSON value.
methodSince v0.0.0-alpha.2
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.

Parameters
NameTypeDescription
predicate optional(code: number) => booleanOptional exit-code predicate (code: number) => boolean.
failOnStderr optionalbooleanIf true, throw CommandError ("VAEL_EXEC_STDERR") when stderr is non-empty.
Returns
this — this when validation passes.
Exceptions
  • CommandError — when validation fails.
import { execSync } from "vael:exec";
const text = execSync(["echo", "ok"]).validate().text();
console.log(text);
classSince v0.0.0-alpha.2vjs & vjs-lite
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
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?).

Overload 1 — new Command(program, options?)
NameTypeDescription
programstringExecutable name/path or non-empty [program, ...args] array.
options optionalCommandOptionsOptional command configuration when argsOrOptions is an argument array.
Overload 2 — new Command(program, args, options?)
NameTypeDescription
programstring—
argsreadonly string[]—
options optionalCommandOptions—
Overload 3 — new Command(argv, options?)
NameTypeDescription
argvreadonly string[]—
options optionalCommandOptions—
Exceptions
  • Error — ("VAEL_EXEC_INVALID_ARGUMENT") when program is empty or contains NUL bytes.
Methods
methodSince v0.0.0-alpha.2
arg(value: string): this;

Append a single literal argument (never shell-expanded).

Parameters
NameTypeDescription
valuestringLiteral argument string (must not contain NUL bytes).
Returns
this — this for fluent chaining.
Exceptions
  • Error — ("VAEL_EXEC_INVALID_ARGUMENT") if value contains a NUL byte.
methodSince v0.0.0-alpha.2
args(values: readonly string[]): this;

Append multiple literal arguments in order (never shell-expanded).

Parameters
NameTypeDescription
valuesreadonly string[]Array of literal argument strings.
Returns
this — this for fluent chaining.
Exceptions
  • Error — ("VAEL_EXEC_INVALID_ARGUMENT") if any argument contains a NUL byte.
methodSince v0.0.0-alpha.2
cwd(path: string): this;

Set the subprocess working directory.

Parameters
NameTypeDescription
pathstringNon-empty NUL-free directory path.
Returns
this — this for fluent chaining.
Exceptions
  • Error — ("VAEL_EXEC_INVALID_ARGUMENT") if path is empty or contains NUL bytes.
methodSince v0.0.0-alpha.2
env(key: string, value: string): this;

Set or override a single environment variable on the subprocess.

Parameters
NameTypeDescription
keystringNon-empty environment variable name (no '=' or NUL).
valuestringEnvironment variable value (no NUL).
Returns
this — this for fluent chaining.
Exceptions
  • Error — ("VAEL_EXEC_INVALID_ARGUMENT") on invalid key or NUL-containing value.
methodSince v0.0.0-alpha.2
envs(vars: Record<string, string | undefined>): this;

Set multiple environment variables on the subprocess.

Parameters
NameTypeDescription
varsRecord<string, string | undefined>Plain object map (undefined values are skipped).
Returns
this — this for fluent chaining.
Exceptions
  • Error — ("VAEL_EXEC_INVALID_ARGUMENT") on invalid keys or NUL-containing values.
methodSince v0.0.0-alpha.2
envRemove(key: string): this;

Remove an inherited or previously configured environment variable.

Parameters
NameTypeDescription
keystringNon-empty environment variable name (no '=' or NUL).
Returns
this — this for fluent chaining.
Exceptions
  • Error — ("VAEL_EXEC_INVALID_ARGUMENT") on invalid key.
methodSince v0.0.0-alpha.2
envClear(): this;

Clear all inherited and previously configured environment variables.

Returns
this — this for fluent chaining.
methodSince v0.0.0-alpha.2
stdin(mode: StdioMode | string | Uint8Array): this;

Configure standard input wiring ("inherit", "piped", "null", or fixed bytes written before closing EOF).

Parameters
NameTypeDescription
modeStdioMode | string | Uint8ArrayStandard input mode or byte payload.
Returns
this — this for fluent chaining.
methodSince v0.0.0-alpha.2
stdout(mode: StdioMode): this;

Configure standard output wiring ("inherit", "piped", or "null").

Parameters
NameTypeDescription
modeStdioModeStandard output wiring mode.
Returns
this — this for fluent chaining.
methodSince v0.0.0-alpha.2
stderr(mode: StdioMode): this;

Configure standard error wiring ("inherit", "piped", or "null").

Parameters
NameTypeDescription
modeStdioModeStandard error wiring mode.
Returns
this — this for fluent chaining.
methodSince v0.0.0-alpha.2
timeout(ms: number): this;

Set a finite positive execution timeout in milliseconds.

Parameters
NameTypeDescription
msnumberTimeout duration in milliseconds (> 0).
Returns
this — this for fluent chaining.
Exceptions
  • Error — ("VAEL_EXEC_INVALID_ARGUMENT") if ms <= 0 or non-finite.
methodSince v0.0.0-alpha.2
killSignal(signal: Signal): this;

Set the initial signal sent when timeout expires (default "SIGTERM").

Parameters
NameTypeDescription
signalSignalSignal name.
Returns
this — this for fluent chaining.
methodSince v0.0.0-alpha.2
killGrace(ms: number): this;

Set the grace period in milliseconds after killSignal before escalating to "SIGKILL" (default 2_000; 0 escalates immediately).

Parameters
NameTypeDescription
msnumberGrace duration in milliseconds (>= 0).
Returns
this — this for fluent chaining.
methodSince v0.0.0-alpha.2
maxOutputBytes(bytes: number): this;

Set the maximum captured byte limit per output stream (default 16 MiB, hard cap 64 MiB).

Parameters
NameTypeDescription
bytesnumberMaximum bytes per stream (0..=67_108_864).
Returns
this — this for fluent chaining.
Exceptions
  • Error — ("VAEL_EXEC_INVALID_ARGUMENT") if bytes exceeds 64 MiB.
methodSince v0.0.0-alpha.2
toArgs(): string[];

Return the full [program, ...args] argv vector configured on this command.

Returns
string[] — Copy of the [program, ...args] argument array.
methodSince v0.0.0-alpha.2
output(): Promise<Output>;

Execute this command asynchronously, capturing stdout and stderr.

Available in vjs (vaeljs) only.

Returns
Promise<Output> — Promise resolving to captured Output.
Exceptions
  • NotFoundOnPathError — if the executable cannot be found.
  • Error — with code: ExecErrorCode on spawn, timeout, or output-limit failure.
methodSince v0.0.0-alpha.2
exec(): Promise<Output>;

Alias for output().

Available in vjs (vaeljs) only.

Returns
Promise<Output> — Promise resolving to captured Output.
methodSince v0.0.0-alpha.2
outputSync(): Output;

Execute this command synchronously, capturing stdout and stderr.

Returns
Output — Captured Output.
Exceptions
  • NotFoundOnPathError — if the executable cannot be found.
  • Error — with code: ExecErrorCode on spawn, timeout, or output-limit failure.
methodSince v0.0.0-alpha.2
execSync(): Output;

Alias for outputSync().

Returns
Output — Captured Output.
methodSince v0.0.0-alpha.2
status(): Promise<CommandStatus>;

Execute this command asynchronously with inherited standard streams by default.

Available in vjs (vaeljs) only.

Returns
Promise<CommandStatus> — Promise resolving to CommandStatus.
Exceptions
  • NotFoundOnPathError — if the executable cannot be found.
  • Error — with code: ExecErrorCode on spawn or timeout failure.
methodSince v0.0.0-alpha.2
run(): Promise<CommandStatus>;

Alias for status().

Available in vjs (vaeljs) only.

Returns
Promise<CommandStatus> — Promise resolving to CommandStatus.
methodSince v0.0.0-alpha.2
statusSync(): CommandStatus;

Execute this command synchronously with inherited standard streams by default.

Returns
CommandStatus — CommandStatus.
Exceptions
  • NotFoundOnPathError — if the executable cannot be found.
  • Error — with code: ExecErrorCode on spawn or timeout failure.
methodSince v0.0.0-alpha.2
runSync(): CommandStatus;

Alias for statusSync().

Returns
CommandStatus — CommandStatus.
methodSince v0.0.0-alpha.2
text(): Promise<string>;

Execute asynchronously, validate zero exit status, and decode stdout as UTF-8 text.

Returns
Promise<string> — Promise resolving to decoded stdout text.
methodSince v0.0.0-alpha.2
lines(): Promise<string[]>;

Execute asynchronously, validate zero exit status, and split stdout into lines.

Returns
Promise<string[]> — Promise resolving to stdout lines.
methodSince v0.0.0-alpha.2
json<T = unknown>(): Promise<T>;

Execute asynchronously, validate zero exit status, and parse stdout as JSON.

Returns
Promise<T> — Promise resolving to parsed JSON value.
methodSince v0.0.0-alpha.2
log(handler: CommandLogHandler | null): this;

Set or clear (null) the single per-instance log hook on this command.

Parameters
NameTypeDescription
handlerCommandLogHandler | nullPre-spawn hook or null to clear.
Returns
this — this for fluent chaining.
Exceptions
  • TypeError — if handler is neither a function nor null.
methodSince v0.0.0-alpha.2
addLogger(handler: CommandLogHandler): CommandLogSubscription;

Attach a disposable per-instance log/audit handler to this command.

Parameters
NameTypeDescription
handlerCommandLogHandlerPre-spawn log/audit callback.
Returns
CommandLogSubscription — Frozen CommandLogSubscription handle.
Exceptions
  • TypeError — if handler is not a function.
methodSince v0.0.0-alpha.2
clearLoggers(): this;

Clear the per-instance log hook and all addLogger subscriptions on this command, marking existing subscriptions inactive.

Returns
this — this for fluent chaining.
methodSince v0.0.0-alpha.2
spawn(): ChildProcess;

Spawn this command as a managed ChildProcess handle with piped streams.

Available in vjs (vaeljs) only.

Returns
ChildProcess — Spawned ChildProcess handle.
Exceptions
  • NotFoundOnPathError — if the executable cannot be found.
  • Error — with code: ExecErrorCode on spawn failure.
classSince v0.0.0-alpha.2vjs only
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.

Properties
PropertyTypeDescriptionSince
pid readonlynumberOS-assigned identifier for the spawned subprocess.v0.0.0-alpha.2
Methods
methodSince v0.0.0-alpha.2
writeStdin(data: string | Uint8Array): Promise<void>;

Write UTF-8 text or raw bytes to the subprocess’s piped stdin and flush.

Parameters
NameTypeDescription
datastring | Uint8ArrayText or bytes to write to stdin.
Returns
Promise<void> — Promise resolving when the write and flush complete.
Exceptions
  • Error — ("VAEL_EXEC_INVALID_ARGUMENT" or "VAEL_EXEC_IO") if stdin is not piped or closed.
methodSince v0.0.0-alpha.2
closeStdin(): void;

Close the parent’s handle to stdin (sending EOF to the subprocess).

Returns
void
methodSince v0.0.0-alpha.2
readStdout(maxBytes?: number): Promise<Uint8Array>;

Read up to maxBytes currently available bytes from piped stdout. Returns an empty Uint8Array on EOF.

Parameters
NameTypeDescription
maxBytes optionalnumberMaximum bytes to read (capped at 64 MiB).
Returns
Promise<Uint8Array> — Promise resolving to the read chunk (Uint8Array).
Exceptions
  • Error — ("VAEL_EXEC_INVALID_ARGUMENT" or "VAEL_EXEC_IO") if stdout is not piped.
methodSince v0.0.0-alpha.2
readStderr(maxBytes?: number): Promise<Uint8Array>;

Read up to maxBytes currently available bytes from piped stderr. Returns an empty Uint8Array on EOF.

Parameters
NameTypeDescription
maxBytes optionalnumberMaximum bytes to read (capped at 64 MiB).
Returns
Promise<Uint8Array> — Promise resolving to the read chunk (Uint8Array).
Exceptions
  • Error — ("VAEL_EXEC_INVALID_ARGUMENT" or "VAEL_EXEC_IO") if stderr is not piped.
methodSince v0.0.0-alpha.2
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.

Parameters
NameTypeDescription
signal optionalSignalSignal to send ("SIGTERM", "SIGKILL", etc.).
Returns
void
Exceptions
  • Error — ("VAEL_EXEC_UNSUPPORTED_SIGNAL" or "VAEL_EXEC_IO") if signaling fails.
methodSince v0.0.0-alpha.2
tryWait(): CommandStatus | null;

Non-blocking poll checking whether the subprocess has exited.

Returns
CommandStatus | null — CommandStatus if exited, or null if still running.
methodSince v0.0.0-alpha.2
wait(): Promise<CommandStatus>;

Wait for the subprocess to exit and reap it.

Returns
Promise<CommandStatus> — Promise resolving to CommandStatus.
methodSince v0.0.0-alpha.2
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).

Parameters
NameTypeDescription
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.
Returns
Promise<Output> — Promise resolving to captured Output.
methodSince v0.0.0-alpha.2
output(): Promise<Output>;

Alias for waitWithOutput().

Returns
Promise<Output> — Promise resolving to captured Output.
methodSince v0.0.0-alpha.2
[Symbol.asyncDispose](): Promise<void>;

Dispose the child handle when leaving an await using block by sending "SIGTERM" if still running and waiting for exit.

Returns
Promise<void> — Promise resolving once the subprocess has been reaped.
classSince v0.0.0-alpha.2vjs & vjs-lite
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]()).

Properties
PropertyTypeDescriptionSince
path readonlystringTarget lock file path associated with this guard.v0.0.0-alpha.2
mode readonlyLockModeLock sharing mode held by this guard ("shared" or "exclusive").v0.0.0-alpha.2
locked readonlybooleantrue while the advisory OS lock is currently held by this guard.v0.0.0-alpha.2
Methods
methodSince v0.0.0-alpha.2
unlock(): void;

Explicitly unlock and close the underlying file handle. Idempotent on subsequent calls after release.

Returns
void
Exceptions
  • Error — ("VAEL_EXEC_IO") if the OS unlock operation fails.
methodSince v0.0.0-alpha.2
[Symbol.dispose](): void;

Release the advisory file lock when exiting a using scope.

Returns
void
methodSince v0.0.0-alpha.2
[Symbol.asyncDispose](): Promise<void>;

Release the advisory file lock when exiting an await using scope.

Returns
Promise<void> — Promise resolving after unlocking.
classSince v0.0.0-alpha.2vjs & vjs-lite
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.

Methods
methodSince v0.0.0-alpha.2
set(name: string, options: PathFinderOptions): this;

Register or update executable lookup configuration under name.

Parameters
NameTypeDescription
namestringRegistry key name.
optionsPathFinderOptionsValidated PathFinderOptions configuration.
Returns
this — this for chaining.
Exceptions
  • TypeError — if name or options is invalid.
methodSince v0.0.0-alpha.2
get(name: string): PathFinderOptions | undefined;

Retrieve a shallow clone of the entry registered under exact key name.

Parameters
NameTypeDescription
namestringRegistry key name.
Returns
PathFinderOptions | undefined — Cloned PathFinderOptions or undefined.
methodSince v0.0.0-alpha.2
has(name: string): boolean;

Return true if exact key name is registered.

Parameters
NameTypeDescription
namestringRegistry key name.
Returns
boolean
methodSince v0.0.0-alpha.2
delete(name: string): boolean;

Delete exact key name from the registry.

Parameters
NameTypeDescription
namestringRegistry key name.
Returns
boolean — true if an entry was removed.
methodSince v0.0.0-alpha.2
clear(): void;

Remove all entries from the registry.

Returns
void
methodSince v0.0.0-alpha.2
find(name: string): PathFinderOptions | undefined;

Find a registered entry by exact key, options.name, options.cached, or ASCII case-insensitive match.

Parameters
NameTypeDescription
namestringExecutable key, name, or cached path.
Returns
PathFinderOptions | undefined — Cloned PathFinderOptions or undefined.
methodSince v0.0.0-alpha.2
findExeSync(name: string): string | undefined;

Synchronously resolve name to an executable file path via env overrides, cache, PATH, and platform fallback candidates.

Parameters
NameTypeDescription
namestringExecutable key or name.
Returns
string | undefined — Resolved executable path, or undefined if not found.
methodSince v0.0.0-alpha.2
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.

Parameters
NameTypeDescription
namestringExecutable key or name.
Returns
Promise<string | undefined> — Promise resolving to the executable path, or undefined.
interfaceSince v0.0.0-alpha.2vjs & vjs-lite
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.

Properties
PropertyTypeDescriptionSince
args optionalreadonly string[]Additional literal argv arguments appended after any arguments passed in the command invocation (never shell-expanded).v0.0.0-alpha.2
cwd optionalstringWorking directory for the subprocess (inherits parent cwd when omitted).v0.0.0-alpha.2
env optionalRecord<string, string | undefined>Environment variables set on the subprocess (undefined entries are omitted or removed).v0.0.0-alpha.2
envRemove optionalreadonly string[]Environment variable names to remove from the subprocess environment.v0.0.0-alpha.2
clearEnv optionalbooleanClear all inherited environment variables before applying env (default false).v0.0.0-alpha.2
stdin optionalStdioMode | string | Uint8ArrayStandard input configuration: "inherit", "piped", "null", or fixed bytes (string or Uint8Array) written to stdin and closed at EOF.v0.0.0-alpha.2
stdout optionalStdioModeStandard output wiring mode ("inherit", "piped", or "null").v0.0.0-alpha.2
stderr optionalStdioModeStandard error wiring mode ("inherit", "piped", or "null").v0.0.0-alpha.2
timeout optionalnumberFinite positive execution timeout in milliseconds. On expiry, sends killSignal and escalates to "SIGKILL" after killGrace / killGraceMs.v0.0.0-alpha.2
timeoutMs optionalnumberAlias for timeout (mutually exclusive with timeout).v0.0.0-alpha.2
killSignal optionalSignalInitial termination signal sent when timeout expires (default "SIGTERM").v0.0.0-alpha.2
killGrace optionalnumberGrace period in milliseconds after killSignal before escalating to "SIGKILL" (default 2_000; 0 escalates immediately).v0.0.0-alpha.2
killGraceMs optionalnumberAlias for killGrace (mutually exclusive with killGrace).v0.0.0-alpha.2
maxOutputBytes optionalnumberMaximum 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 optionalCommandLogHandlerOptional per-instance execution logging / audit hook invoked right before spawning the command. Throwing from this hook aborts spawn.v0.0.0-alpha.2
interfaceSince v0.0.0-alpha.2vjs & vjs-lite
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.

Properties
PropertyTypeDescriptionSince
file readonlystringResolved executable name or path about to be executed.v0.0.0-alpha.2
args readonlyreadonly string[]Frozen snapshot of argument strings passed to the executable (excluding argv[0]).v0.0.0-alpha.2
cwd readonly optionalstringConfigured 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
interfaceSince v0.0.0-alpha.2vjs & vjs-lite
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.

Properties
PropertyTypeDescriptionSince
active readonlybooleantrue while the handler subscription remains registered and active.v0.0.0-alpha.2
Methods
methodSince v0.0.0-alpha.2
dispose(): void;

Unregister this specific log handler subscription idempotently.

Returns
void
methodSince v0.0.0-alpha.2
[Symbol.dispose](): void;

Dispose this subscription automatically when exiting a using block.

Returns
void
interfaceSince v0.0.0-alpha.2vjs & vjs-lite
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.

Properties
PropertyTypeDescriptionSince
name stringCanonical executable name for this entry.v0.0.0-alpha.2
executable optionalstringExecutable binary name or explicit path to look up instead of name.v0.0.0-alpha.2
envVariable optionalstringEnvironment variable name checked for an explicit executable path override.v0.0.0-alpha.2
cached optionalstringCached resolved path returned when noCache is not true.v0.0.0-alpha.2
noCache optionalbooleanDisable caching resolved paths on this entry when true.v0.0.0-alpha.2
windows optionalreadonly string[]Ordered candidate fallback paths on Windows (supports ${VAR} and %VAR% expansion).v0.0.0-alpha.2
linux optionalreadonly string[]Ordered candidate fallback paths on Linux (supports ${VAR} and %VAR% expansion).v0.0.0-alpha.2
darwin optionalreadonly string[]Ordered candidate fallback paths on macOS (darwin; supports ${VAR} and %VAR% expansion).v0.0.0-alpha.2
interfaceSince v0.0.0-alpha.2vjs & vjs-lite
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.

Properties
PropertyTypeDescriptionSince
code readonlynumberExit status code (128 + signo if killed by a signal on Unix, -1 if unavailable).v0.0.0-alpha.2
signal readonlystring | nullTermination signal name (for example "SIGTERM" or "SIGKILL"), or null when the subprocess exited normally.v0.0.0-alpha.2
success readonlybooleantrue when the subprocess exited with status 0 and did not time out.v0.0.0-alpha.2
timedOut readonlybooleantrue when execution exceeded timeout and the subprocess was terminated.v0.0.0-alpha.2
interfaceSince v0.0.0-alpha.2vjs & vjs-lite
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.

Properties
PropertyTypeDescriptionSince
mode optionalLockModeAdvisory lock sharing mode (default "exclusive").v0.0.0-alpha.2
create optionalbooleanCreate the target lock file if it does not already exist (default true).v0.0.0-alpha.2
nonBlocking optionalbooleanFail immediately with "VAEL_EXEC_LOCK_WOULD_BLOCK" if a conflicting lock is held (default false).v0.0.0-alpha.2
timeout optionalnumberOptional bounded wait duration in milliseconds before failing with "VAEL_EXEC_LOCK_TIMEOUT".v0.0.0-alpha.2
interfaceSince v0.0.0-alpha.2vjs & vjs-lite
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.

Properties
PropertyTypeDescriptionSince
exitCode readonly optionalnumberExit status code from the failed subprocess.v0.0.0-alpha.2
signal readonly optionalSignal | string | nullTermination signal name, or null.v0.0.0-alpha.2
timedOut readonly optionalbooleanWhether the failure resulted from exceeding timeout.v0.0.0-alpha.2
output readonly optionalOutputCaptured Output from the failed command, when available.v0.0.0-alpha.2
fileName readonly optionalstringTarget executable name/path, when applicable.v0.0.0-alpha.2
typeSince v0.0.0-alpha.2vjs & vjs-lite
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.

typeSince v0.0.0-alpha.2vjs & vjs-lite
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/null or NUL
typeSince v0.0.0-alpha.2vjs & vjs-lite
export type Signal =
  | "SIGINT"
  | "SIGTERM"
  | "SIGKILL"
  | "SIGHUP"
  | "SIGQUIT"
  | "SIGUSR1"
  | "SIGUSR2";

Explicit subprocess termination or control signal.

typeSince v0.0.0-alpha.2vjs & vjs-lite
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
typeSince v0.0.0-alpha.2vjs & vjs-lite
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.

constSince v0.0.0-alpha.2vjs & vjs-lite
export const pathFinder: PathFinder;

Default singleton PathFinder registry consulted automatically when executing a Command whose program matches a registered entry.