This release is 3 versions behind 1.0.1 — the latest version of @codemonument/puppet-process. Jump to latest
@codemonument/puppet-process@0.1.1Built and signed on GitHub ActionsBuilt and signed on GitHub Actions
Built and signed on GitHub Actions
Works with
•JSR Score94%•This package works with DenoIt is unknown whether this package works with Cloudflare Workers

Downloads2/wk
•Publisheda year ago (0.1.1)
A wrapper around the native subcommand execution apis of deno (later: bun, node) to easily automate cli processes from the outside.
Puppet Process
A wrapper around the native subcommand execution apis of deno (later: bun, node) to easily automate cli processes from the outside.
Provides (planned):
-
Mode 1: One-Shot Command execution
- starts the command, returns a promise and waits for it to finish
- returns all sort of information about the command (stdout, stderr, exit code, etc.)
-
Mode 2:Interactive Command execution
-
start a command and get some sort of "session" object to interact with it
-
send input to the command
-
receive output from the command as Uint8Array or string lines
Example cli: sftp
Example (with Deno)
import {simpleCallbackTarget} from '@codemonument/rx-webstreams'; import {assertEquals, assertExists, assertRejects} from '@std/assert'; import {PuppetProcess} from '@codemonument/puppet-process/deno'; import {delay} from '@std/async'; const process = new PuppetProcess({ command: `cat`, }); process.std_out.pipeTo( simpleCallbackTarget(chunk => { assertEquals(chunk, 'Hello, world!'); }) ); const writer = process.std_in.getWriter(); writer.write('Hello, world!'); process.start(); await delay(50); // close the writer explicitly to avoid dangling stdin stream after child process has finished await writer.close(); // CAUTION: Some cli-tools, like "cat", will exit when the writer for stdin is closed, // since this closing sends an EOF signal to the child process! // SO: we only need to wait for exit here, instead of killing the process. await process.waitForExit();
Credits
- draw inspiration from deno_simple_exec
Changelog
0.1.1 - 2024-10-21
- improved documentation, as suggested by jsr
0.1.0 - 2024-10-21 - initial release
Features:
- creating a puppet process with deno
- sending input to the process
- receiving output from the process
- waiting for the process to finish
- killing the process
Built and signed on
GitHub Actions
Add Package
deno add jsr:@codemonument/puppet-process
Import symbol
import * as puppet_process from "@codemonument/puppet-process";
Import directly with a jsr specifier
import * as puppet_process from "jsr:@codemonument/puppet-process";