New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

command-runner

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

command-runner

Simple command runner.

latest
Source
npmnpm
Version
0.2.2
Version published
Maintainers
1
Created
Source

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

NameTypeRequiredDescription
cmdArrayyesThe command to run
cwdstringnoThe command working directory. Default is current directory.
dependsArraynoThe names of command dependencies. Name must be defined in configuration.
logObjectnoThe command output log configuration.
waitObjectnoThe command start wait condition configuration.
exit_on_successbooleannoIndicate if runner gracefully exit if the command terminate with zero exit code. Default is false.
abort_on_errorbooleannoIndicate if runner gracefully abort if the command terminate with non-zero exit code. Default is true.

"log" configuration object

NameTypeRequiredDescription
typestringyesThe output log type : file, output, stdout or stderr.
optionsObjectnoThe 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 :

NameTypeRequiredDescription
namestringyesThe filename.
inputstringnoThe stream input : output, stdout or stderr. Default is output.
stream_optionsObjectnoThe 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

NameTypeRequiredDescription
typestringyesThe wait condition type : output, socket, done, or timer.
optionsObjectnoThe wait condition options.

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

NameTypeRequiredDescription
matchstringyesThe string to match.
timeoutnumbernoThe wait timeout in milliseconds. Default is 10000.

socket: wait for a socket using the following options :

NameTypeRequiredDescription
portnumberyesThe port number.
hoststringnoThe hostname or ip address. Default is localhost
timeoutnumbernoThe wait timeout in milliseconds. Default is 10000.
intervalnumbernoThe connect retry interval in milliseconds. Default is 200.

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

NameTypeRequiredDescription
timeoutnumbernoThe wait timeout in milliseconds. Must be greater than or equal to 100.

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

NameTypeRequiredDescription
durationnumberyesThe wait duration in milliseconds. Must be greater than or equal to 100.

FAQs

Package last updated on 13 Mar 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts