Built and signed on GitHub ActionsBuilt and signed on GitHub Actions
Built and signed on GitHub Actions
latest
lowlighter/libsWorks with
•JSR Score94%•This package works with Deno
License
•MIT
Downloads13/wk
•Published3 weeks ago (3.3.2)
⏯️ Utilities to run subprocess.
⏯️ Run subprocesses
Warning
Deno exclusive!
📑 Examples
Run a command
import { command } from "./command.ts" // Commands are run asynchronously, and support Deno.command options alongside additional options // For example, stdio can also be set to a Logger level too or you can automatically append an extension when running on Windows await command("deno", ["--version"], { stdout: "debug", stderr: "piped", winext: ".exe" }) // Commands can be run synchronously too, and can also throw an error automatically when the process exits with a non-zero code command("deno", ["--version"], { sync: true, throw: true })
Writing to stdin
import { command } from "./command.ts" const { stdout } = await command("deno", ["repl"], { env: { NO_COLOR: "true" }, // Passing a callback will automatically set `stdin` to `"piped"` // You can then write to the process using utility functions callback: async ({ i, stdio, write, close, wait }) => { if ((!stdio.stdout.includes("exit using")) || i) { return } await write("console.log('hello')") await wait(1000) close() }, }) console.assert(stdout.includes("hello"))
✨ Features
- Supports
stdininteractivity through callbacks.- Make it possible to monitor
stdoutandstderrcontent and react accordingly.
- Make it possible to monitor
- Auto-detects os and can automatically append an extension when running on Windows.
- Supports both
syncandasyncmodes in a single function.- Optionally decide to throw an error when the process exits with a non-zero code.
- Generates a
stdiohistory that contains timestamped entries with configurable buffering
🕊️ Migrating from 2.x.x to 3.x.x
Version 3.x.x and onwards require Deno 2.x.x or later.
📜 Licenses
Copyright (c) Simon Lecoq <@lowlighter>. (MIT License) https://github.com/lowlighter/libs/blob/main/LICENSE
Built and signed on
GitHub Actions
Add Package
deno add jsr:@libs/run
Import symbol
import * as run from "@libs/run";
Import directly with a jsr specifier
import * as run from "jsr:@libs/run";