class ProcessEnumerable

Enumerable for process output with additional process-specific properties.

Extends Enumerable<Uint8Array> with process management capabilities. Use .lines property to get line-based output, or iterate over raw bytes.

Important: Always consume the process output (via .lines.collect(), .lines.forEach(), etc.) or the process will leak resources.

Error Handling: Processes that exit with non-zero codes throw ExitCodeError when you consume their output. Wrap in try-catch to handle.

Examples

Basic usage

import { run } from "jsr:@j50n/proc";

const lines = await run("ls", "-la").lines.collect();

Check exit status

import { run } from "jsr:@j50n/proc";

const p = run("some-command");
await p.lines.collect(); // Consume output
const status = await p.status; // .status is a property, not a method
console.log(`Exit code: ${status.code}`);

Handle errors

import { run } from "jsr:@j50n/proc";

try {
  await run("false").lines.collect();
} catch (error) {
  if (error.code) {
    console.error(`Failed with code ${error.code}`);
  }
}

Constructors

new
ProcessEnumerable(process: Process<S>)

Type Parameters

Properties

readonly
pid: number

Process PID.

readonly
status: Promise<Deno.CommandStatus>

Process exit status.

Important: This is a property that returns a Promise, not a method. Use await p.status not await p.status().

The Promise resolves when the process exits. You should consume the process output before or concurrently with checking status to avoid resource leaks.