npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

textrun-shell

v0.6.0

Published

This package provides [Text-Runner](https://github.com/kevgo/text-runner) actions for documenting console commands to be executed by the reader.

Downloads

89

Readme

Text-Runner Shell Actions

This package provides Text-Runner actions for documenting console commands to be executed by the reader.

Setup

To add this package as a Text-Runner plugin:

You can define the absolute path of binaries that your documentation tests call by creating a file textrun-shell.js file in the root directory of your documentation. Here is an example:

import * as path from "path"
import * as url from "url"

const __dirname = url.fileURLToPath(new URL(".", import.meta.url))
const foo_path = path.join(__dirname, "bin", "foo")
// console.log(`calling "foo" in the documentation now runs ${foo_path}`)

export default {
  globals: {
    "foo": foo_path
  }
}

shell/command

The shell/command action runs a shell command and waits until it finishes. The shell/command-output action verifies the output of the most recently executed shell command.

As an example, here is a hypothetical tutorial for how to use the Linux shell:

The "echo" command prints text on the command line. For example, let's run:

<pre type="shell/command">
echo Hello world!
</pre>

Some tutorials print a dollar sign at the beginning of the command to execute, indicating an interactive command prompt. These dollar signs are ignored.

allow-error attribute

By default, this step fails if the subshell command exits with a non-zero exit code. To allow errors, add the allow-error attribute, like so:

<pre type="shell/command" allow-error>
echo Hello world!
</pre>

command attribute

You can provide the command to run via an HTML attribute:

The "echo" command prints text on the command line. For example, let's run:

<pre type="shell/command" command="echo Hello world!"></pre>

shell/command-output

The shell/command-output action verifies the output of the most recently executed shell command.

Here is the next paragraph of our hypothetical tutorial for the Linux shell:

It welcomes us with a nice greeting:

<pre type="shell/command-output">
Hello world!
</pre>

Some tutorials print a dollar sign at the beginning of the command to execute, indicating an interactive command prompt. These dollar signs are ignored.

shell/command-with-input

You can run a shell command and enter text into it with the shell/command-with-input action.

As an example, let's say we have a command-line tool written in JavaScript called greeter.js:

import * as readline from "readline"
var rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
  terminal: false
})

rl.question("your name\n", name => {
  rl.question("which day is today\n", day => {
    console.log(`Hello ${name}, happy ${day}!`)
    rl.close()
    process.exit()
  })
})

Run this tool on the command line

node greeter.js

and provide user input with an HTML table:

It prints:

If the table contains multiple columns, the first column contains output to wait for, and the last one text to enter once the output from the first column has appeared. Middle columns are ignored. <th> elements are considered descriptions and are also ignored.

command attribute

You can provide the command to run via the command HTML attribute. As an example, if you run the previous script with this other input:

Then it prints:

shell/server

Long-running processes, for example web or database servers, keep running while Text-Runner continues executing other actions.

As an example, let's say we write a tutorial about developing a web server, have just created an implementation in file server.js:

console.log("server is running")
setTimeout(() => {}, 100_000)

Our tutorial instructs the user to start this long-running server to run in parallel with Text-Runner with the shell/server action:

Start the server:

<pre type="shell/server">
node server.js
</pre>

command attribute

You can also provide the command to start the server via the command attribute.

shell/server-output

After we started a long-running server through shell/server above, we can await specific output from it using the shell/server-output action.

Here is the next paragraph of our hypothetic server tutorial:

Wait until the server is fully booted up:

<pre type="shell/server-output">
server is running
</pre>

shell/stop-server

Stop a long-running process with the shell/stop-server action.

Here is the final part of our hypothetical server tutorial:

When you are done, stop the server:

<pre type="shell/stop-server">
killall node
</pre>