Built and signed on GitHub ActionsBuilt and signed on GitHub Actions
Tools for working with spawned child processes.
- @sys/process
all symbols
Examples
Running a short lived shell command (synchronous):
Running a short lived shell command (synchronous):
import { Process } from '@sys/process'; const sh = Process.sh('./path/to/cwd'); const res = await sh.run('echo foo'); // ← res.code == 0 (success) // OR ↓ const args = ['eval', 'console.log("👋 hello world")']; const res = await Process.invoke({ args });
Running an interactive command with inherited terminal stdio:
Running an interactive command with inherited terminal stdio:
import { Process } from '@sys/process'; await Process.inherit({ cmd: 'deno', args: ['task', 'help'] });
Notes:
Process.inheritdoes not capture stdout/stderr.silenthas no effect forinherit.FORCE_COLORdefaults to on (override by settingenv.FORCE_COLOR).
Spawning a long-running child process (asynchronous):
Spawning a long-running child process (asynchronous):
import { Process } from '@sys/process'; const readySignal = Process.Signal.ready; const cmd = ` Deno.serve({ port: 1234 }, () => new Response('👋 hello world')); console.info('${Process.Signal.ready}'); `; const args = ['eval', cmd]; const proc = await Process.spawn({ args, readySignal, silent: true }).whenReady(); await proc.whenReady(); // ... await proc.dispose();
Variables
Open helpers for launching URLs and paths via the OS default handler in a detached child process.
Package metadata.
Host and child process capabilities. https://docs.deno.com/api/deno/~/Deno.Command
Variables
Host and child process capabilities. https://docs.deno.com/api/deno/~/Deno.Command
Host and child process capabilities. https://docs.deno.com/api/deno/~/Deno.Command
Namespaces
Host and child-process contracts for Process.
Local port inspection contracts.
Process termination contracts.
Port listener termination contracts.
Type Aliases
Process command for opening a URL.
Options for Open.invokeDetached.
- silent: booleanNo documentation available
Open helpers for launching URLs and paths via the OS default handler in a detached process.
- invokeDetached: () => voidcwd: t.StringDir,url: t.StringUrl,opts?: OpenInvokeOptions
Fire-and-forget open of a URL in the default handler.
- resolveCommand: () => OpenCommandtarget: t.StringUrl,os?: OpenOsInput
Resolve the platform-specific command for opening a URL.
Supported OS identifiers for command resolution.
OS discriminator accepted by Open.resolveCommand.
Arguments passed to Process.capture.
- args: string[]No documentation available
- cmd: stringNo documentation available
- cwd: stringNo documentation available
- env: t.Process.EnvNo documentation available
- killGraceMs: t.MsecsNo documentation available
- maxStderrBytes: numberNo documentation available
- maxStdoutBytes: numberNo documentation available
- signal: AbortSignalNo documentation available
- timeoutMs: t.MsecsNo documentation available
Shared bounded capture output fields.
- stderr: Uint8ArrayNo documentation available
- stderrTruncated: booleanNo documentation available
- stdout: Uint8ArrayNo documentation available
- stdoutTruncated: booleanNo documentation available
- text: { readonly stdout: string; readonly stderr: string; }No documentation available
- toString(): stringNo documentation available
& { readonly outcome: "cancelled"; readonly status: Deno.CommandStatus | null; readonly code: number | null; readonly success: false; readonly signal: Deno.Signal | null; readonly termination: CaptureTermination<"cancelled">; }
Capture result for a child process stopped by cancellation.
& { readonly outcome: "exited"; readonly status: Deno.CommandStatus; readonly code: number; readonly success: boolean; readonly signal: Deno.Signal | null; readonly termination: CaptureNoTermination; }
Capture result for a child process that exited before timeout/cancellation.
& { readonly outcome: "failed-to-start"; readonly status: null; readonly code: null; readonly success: false; readonly signal: null; readonly termination: CaptureNoTermination; readonly error: unknown; }
Capture result for command construction/spawn substrate failures.
Termination metadata for naturally exited capture results.
| CaptureTimedOutOutput
| CaptureCancelledOutput
| CaptureFailedToStartOutput
Terminal output variants returned by Process.capture.
Termination metadata for timeout/cancellation capture results.
& { readonly outcome: "timed-out"; readonly status: Deno.CommandStatus | null; readonly code: number | null; readonly success: false; readonly signal: Deno.Signal | null; readonly termination: CaptureTermination<"timeout">; }
Capture result for a child process stopped by timeout.
Environment values passed through to a child process.
Event fired when data is emitted by the process.
Handles events on a process.
& { readonly pid: number; readonly $: t.Observable<t.Process.Event>; readonly is: { readonly ready: boolean; }; whenReady(fn?: ReadyHandler): Promise<t.Process.Handle>; onStdOut(fn: t.Process.EventHandler): t.Process.Handle; onStdErr(fn: t.Process.EventHandler): t.Process.Handle; }
The output from the Process.spawn command that represents
a running child-process.
Exit status from an inherited-stdio process. NB: stdout/stderr are not captured when stdio is inherited.
Arguments passed to the Process.invoke method.
Host and child process capabilities. https://docs.deno.com/api/deno/~/Deno.Command
- Port: Port.Lib
Local port inspection helpers.
- Script: ScriptLib
Script helpers for preparing shell template strings.
- Signal: { readonly ready: "PROCESS_READY"; }
Shared process signals.
- Terminate: Terminate.Lib
Process termination helpers.
- capture(config: t.Process.CaptureArgs): Promise<t.Process.CaptureOutput>
Execute a no-shell argv command with bounded stdout/stderr capture.
- inherit(config: t.Process.InvokeArgs): Promise<t.Process.InheritOutput>
Execute a command with child stdio inherited from the parent terminal. Useful for interactive tools/prompts.
- invoke(config: t.Process.InvokeArgs): Promise<t.Process.Output>
Execute a command on a child process and wait for response.
- invokeDetached(config: t.Process.InvokeArgs): { pid: number; }
Execute a command in a fire-and-forget manner, detaching stdio and unref'ing the child so the host process is free to exit immediately.
- isRunning(pid: number): boolean
Determine whether an OS process currently accepts signal delivery.
- run(): Promise<t.Process.Output>script: string,opts?: t.Process.ShellOptions
Runs a multiline shell script with sane defaults for strictness and output control.
- sh(options?: t.Process.ShellOptions): t.Process.Shell
Run an command.
- spawn(config: t.Process.SpawnArgs): t.Process.Handle
Spawn a child process to run a -like command and retrieve a streaming handle to monitor and control it.
- stdout: Stdout
Canonical host-process stdout capability.
Command output with lazy decoded text.
- code: numberNo documentation available
- signal: Deno.Signal | nullNo documentation available
- stderr: Uint8ArrayNo documentation available
- stdout: Uint8ArrayNo documentation available
- success: booleanNo documentation available
- text: { readonly stdout: string; readonly stderr: string; }No documentation available
- toString(): stringNo documentation available
Port target shorthand or structured target.
Local port inspection helper API.
- listeners(input: Input): Promise<readonly Listener[]>
Discover TCP LISTEN sockets matching a local port target.
TCP listener discovered for a local port target.
Supported listener protocol for local port inspection.
Normalized local port target.
Structured local port target.
Handler for the Process.whenReady method.
Arguments passed to the Process.whenReady method.
A function that determines if a process/stdio event is a "ready" signal.
Script helpers for preparing shell template strings.
A shell command ("sh").
Options passed to the Process.sh method.
& { until?: t.UntilInput; readySignal?: string | t.Process.ReadySignalFilter; }
Arguments passed to the Process.spawn method.
Ways to handle stdin on a spawned child process.
Canonical host-process stdout capability.
- isTerminal(): boolean
Determine whether stdout is attached to a terminal.
- write(text: string): void
Write complete UTF-8 text synchronously to stdout.
Direction of a STDIO stream.
Signal attempt emitted while terminating an arbitrary process id.
Process termination helper API.
Options for arbitrary process id termination.
Result from terminating listener process ids for a local port target.
| "terminated"
| "killed"
| "partial"
| "still-running"
Aggregate status for port listener cleanup.
Result from arbitrary process id termination.
Result status for arbitrary process id termination.