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 🙏

© 2024 – Pkg Stats / Ryan Hefner

command-runner

v0.2.2

Published

Simple command runner.

Downloads

18

Readme

command-runner

A simple command runner, inspired from Whiskey process runner.

Installation

npm install -g command-runner

This will install the command-runner module globally and add the cr cli tool to your PATH.

Usage

cr --config filename.json [--debug]

Configuration file

This JSON file is used to specify all the commands to run asynchronously.

Example configuration file :


{
  "http-server": {
    "cmd": [ "http-server", "-p", "8000", "./" ],
    "log": {
      "type": "file",
      "options": {
        "name": "http-server.log"
      }
    },
    "wait": {
      "type": "socket",
      "options": {
        "host": "127.0.0.1",
        "port": "8000",
        "timeout": "3000"
      }
    }
  },
  "localtunnel": {
    "cmd": [ "lt", "--port", "8000" ],
    "wait": {
      "type": "output",
      "options": {
        "match": "your url is:",
        "timeout": "3000"
      }
    }
  },
  "test": {
    "cmd": [ "tape", "tests/**/*.js" ],
    "depends": [ "http-server", "localtunnel" ],
    "log": {
      "type": "output"
    },
    "exit_on_success": true
  }
}

Options

| Name | Type | Required | Description | | :--- | :--: | :------: | :---------- | | cmd | Array | yes | The command to run | | cwd | string | no | The command working directory. Default is current directory. | | depends | Array | no | The names of command dependencies. Name must be defined in configuration. | | log | Object | no | The command output log configuration. | | wait | Object | no | The command start wait condition configuration. | | exit_on_success | boolean | no | Indicate if runner gracefully exit if the command terminate with zero exit code. Default is false. | | abort_on_error | boolean | no | Indicate if runner gracefully abort if the command terminate with non-zero exit code. Default is true. |

"log" configuration object

| Name | Type | Required | Description | | :--- | :--: | :------: | :---------- | | type | string | yes | The output log type : file, output, stdout or stderr. | | options | Object | no | The output log options. |

output: respectively redirect command process stdout and stderr to runner stdout and stderr. Has no options.

stdout: redirect only command process stdout to runner stdout. Has no options.

stderr: redirect only command process stderr to runner stderr. Has no options.

file: redirect command process output to a file using the following options :

| Name | Type | Required | Description | | :--- | :--: | :------: | :---------- | | name | string | yes | The filename. | | input | string | no | The stream input : output, stdout or stderr. Default is output. | | stream_options | Object | no | The fs.createStream options. |

fs.createStream default behavious is open file for writing. The file is created (if it does not exist) or truncated (if it exists). To append, just set stream_options to {"flags": "a"}.

"wait" configuration object

| Name | Type | Required | Description | | :--- | :--: | :------: | :---------- | | type | string | yes | The wait condition type : output, socket, done, or timer. | | options | Object | no | The wait condition options. |

output: wait for an output string (stdout and stderr) to match using the following options :

| Name | Type | Required | Description | | :--- | :--: | :------: | :---------- | | match | string | yes | The string to match. | | timeout | number | no | The wait timeout in milliseconds. Default is 10000. |

socket: wait for a socket using the following options :

| Name | Type | Required | Description | | :--- | :--: | :------: | :---------- | | port | number | yes | The port number. | | host | string | no | The hostname or ip address. Default is localhost | | timeout | number | no | The wait timeout in milliseconds. Default is 10000. | | interval | number | no | The connect retry interval in milliseconds. Default is 200. |

done: wait for a process to run and exit with success code using the following options :

| Name | Type | Required | Description | | :--- | :--: | :------: | :---------- | | timeout | number | no | The wait timeout in milliseconds. Must be greater than or equal to 100. |

timer: wait for a timer duration using the following options :

| Name | Type | Required | Description | | :--- | :--: | :------: | :---------- | | duration | number | yes | The wait duration in milliseconds. Must be greater than or equal to 100. |