close
Skip to main content

@sys/process@0.0.317
Built and signed on GitHub Actions

Works with
This package works with Deno, Browsers
This package works with Deno
This package works with Browsers
JSR Score100%
License
MIT
Downloads68/wk
Published2 weeks ago (0.0.317)

Tools for working with spawned child processes.

Examples

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:

import { Process } from '@sys/process';

await Process.inherit({ cmd: 'deno', args: ['task', 'help'] });

Notes:

  • Process.inherit does not capture stdout/stderr.
  • silent has no effect for inherit.
  • FORCE_COLOR defaults to on (override by setting env.FORCE_COLOR).

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

v
Open: t.OpenLib

Open helpers for launching URLs and paths via the OS default handler in a detached child process.

v
pkg: Pkg

Package metadata.

v
Process: t.Process.Lib

Host and child process capabilities. https://docs.deno.com/api/deno/~/Deno.Command

Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.

Add Package

deno add jsr:@sys/process

Import symbol

import * as Host_stdout_and_spawned_child_process_capabilities_for_modern_POSIX_based_systems__macOS__Linux__and_similar__unix_like__environments__using_Deno__aka___WinterTC__https___wintertc_org___compatible__runtimes__ from "@sys/process";
or

Import directly with a jsr specifier

import * as Host_stdout_and_spawned_child_process_capabilities_for_modern_POSIX_based_systems__macOS__Linux__and_similar__unix_like__environments__using_Deno__aka___WinterTC__https___wintertc_org___compatible__runtimes__ from "jsr:@sys/process";