method Enumerable.prototype.run
Enumerable.prototype.run<S>(
options: ProcessOptions<S>,
...cmd: Cmd,
): Run<S, T>

Run a process, piping this iterable's output to its stdin.

This allows chaining processes together like shell pipes. The current iterable's data is written to the new process's stdin, and the new process's stdout becomes the new iterable.

Examples

Chain processes together

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

// Equivalent to: echo "HELLO" | tr "A-Z" "a-z"
const result = await run("echo", "HELLO")
  .run("tr", "A-Z", "a-z")
  .lines
  .first;
// "hello"

Multi-stage pipeline

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

const result = await run("cat", "data.txt")
  .run("grep", "error")
  .run("wc", "-l")
  .lines
  .first;

Type Parameters

Parameters

Options.

...cmd: Cmd

Return Type

Run<S, T>

A child process instance.

Enumerable.prototype.run(...cmd: Cmd): Run<unknown, T>

Run a process.

Parameters

...cmd: Cmd

Return Type

Run<unknown, T>

A child process instance.