GraphReFlyTS

API Reference

fromSpawn()

Stream stdout, stderr, and exit events from a Node child process.

Import

import { fromSpawn } from "@graphrefly/ts/sources/node";

Signature

function fromSpawn(
	cmd: string,
	args: readonly string[] = [],
	opts: FromSpawnOptions = {},
): Operator<never, SpawnEvent>

Parameters

ParameterTypeDescription
cmdstringExecutable name or absolute path passed to child_process.spawn.
argsreadonly string[]Arguments passed to the child process.
optsFromSpawnOptionsOptional cwd, env, stdio, shell, cancellation, and kill-grace controls.

Returns

A node-only source operator that emits SpawnEvent DATA values and terminal ERROR/COMPLETE events.

Example

import { graph } from "@graphrefly/ts/graph";
import { fromSpawn } from "@graphrefly/ts/sources/node";

const g = graph();
const ls = g.initNode(fromSpawn("git", ["status", "--short"], { cwd: process.cwd() }), []);

Source

packages/ts/src/sources/node.ts