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

exit-code-monitor

v1.1.3

Published

Command line tool for repeatedly calling and monitoring the exit status of a set of commands. Useful for waiting for a set of conditions to occur before performing an operation.

Downloads

318

Readme

Exit Code Monitor

Command line tool for repeatedly calling and monitoring the exit status of a set of commands. Useful for waiting for a set of conditions to occur before performing an operation.

Version Downloads Package Quality Pipeline Status Coverage

Usage

Each non-option argument is interpreted as a command to be repeatedly
executed in a subshell until all provided commands meet their
expectations. Commands are run within a subshell. Please be careful of
command injection!

Target state
  -m, --mode         How the commands following this option are
                     expected to exit:

                     pass|p expects a zero exit code.

                     fail|f expects a non-zero exit code (and not
                     timeout).

                     code|c expects a specific exit code (see
                     --code|-c).

                     info|i expects any exit code. The command will
                     be run/displayed, but any exit code allows the
                     monitor to exit. If all commands have this
                     mode, exit-code-monitor will not auto-exit.

     [string] [choices: "pass", "p", "fail", "f", "code", "c", "info",
                                                "i"] [default: "pass"]
  -c, --code         Command is expected to return this exit code
                     NOTE: ONLY USED IF --mode=code           [number]
  -x, --consecutive  Command must meet expectations this many times in
                     a row [minimum: 1]          [number] [default: 1]
  -H, --latch        Command will stop running the first time it meets
                     all of its expectations. In interactive mode it
                     can be restarted by pressing enter or space with
                     the command highlighted.
                                            [boolean] [default: false]

Identification
  -l, --label  Set the short string to show for the next command (only
               applies to next command)
                             [string] [default: first word of command]

Timing
  -t, --timeout      After this many seconds send kill signal to
                     command and use timeout exit code [minimum: 1]
                                                [number] [default: 30]
      --timeoutcode  When timeout is reached use this exit code (may
                     also be "null" to prevent timeout from matching
                     any expectation)         [number] [default: null]
  -d, --delay        When command exits, delay this many seconds
                     before re-running command [minimum: 1]
                                                 [number] [default: 1]

Command Context
  -p, --pwd     Process working directory when starting command
                                            [string] [default: $(pwd)]
  -P, --path    Prepend PATH with this string[string] [default: $PATH]
  -o, --stdout  stdout of commands will be formatted "$title:
                $stdoutLine" and appended to the specified file
                                         [string] [default: /dev/null]
  -e, --stderr  stderr of commands will be formatted "$title:
                $stderrLine" and appended to the specified file
                                         [string] [default: /dev/null]

Output
  -T, --tty          Force TTY display on or off
                                         [boolean] [default: detected]
      --color        Force color when in non-TTY mode
                                            [boolean] [default: false]
  -r, --report       When not using TTY output, emit a report this
                     frequently in seconds [minimum: 1]
                                                [number] [default: 10]
  -R, --rate         When using TTY output, refresh the screen at
                     LEAST every so many milliseconds [minimum: 100]
                                               [number] [default: 250]
  -L, --limit        When using TTY output, refresh the screen at MOST
                     every so many milliseconds [minimum: 100]
                                               [number] [default: 100]
  -v, --verbose      When not using TTY output, make each emitted
                     update multiline (default is a single line per
                     udpate)                                 [boolean]
  -q, --quiet        Do not show anything on the screen, only return
                     exit code when interrupted or complete  [boolean]
  -C, --commandterm  Use this word to represent the commands specified
                     to be watch.        [string] [default: "Command"]
  -M, --metterm      Use this word to represent commands which are
                     meeting their expectations.
                                            [string] [default: "GOOD"]
  -U, --unmetterm    Use this word to represent commands that are not
                     meeting thier expectations.
                                             [string] [default: "BAD"]
  -W, --waitterm     Use this word when we have not yet received any
                     result for a command.
                                         [string] [default: "PENDING"]
  -g, --log          Write a jsonl winston log to the provided file
                     name.             [string] [default: "/dev/null"]
  -G, --level        What winston log level to use.
        [string] [choices: "error", "warn", "info", "http", "verbose",
                                  "debug", "silly"] [default: "silly"]

Options:
  -h, --help     Show help                                   [boolean]
  -V, --version  Show version number                         [boolean]

Examples:

Wait for all commands to succeed:

$ npx exit-code-monitor command1 command2 command3

Wait for all commands to fail:

$ npx exit-code-monitor --mode=fail command1 command2 command3

Wait for commands 1, 2, 5, and 6 to succeed, and for 3 and 4 to fail

$ npx exit-code-monitor \
  --mode=pass command1 command2 \
  --mode=fail command3 command4 \
  --mode=pass command5 command6

Note that the above can be written more concisely this way, but that
the commands will then be listed in the order 1 2 5 6 3 4:

$ npx exit-code-monitor \
  command1 command2 command5 command6 \
  --mode=fail command3 command4

Wait for the command to have exit code 123 using short options:

$ npx exit-code-monitor -m c -c 123 command1