parallelshell Documentation

repository·master·Indexed 19 days ago

https://github.com/darkguy2008/parallelshell

An npm module and CLI tool for invoking multiple shell commands in parallel. It provides process management that ensures if one process fails, all others are terminated and the error is reported. Features include cross-platform support for Unix and Windows, automatic cleanup of sibling processes, and a --wait flag to prevent automatic termination upon failure.

Tokens
715
Snippets
5
Records
5
Agent score
18%

What's inside parallelshell

  1. Run shell commands in parallel with parallelshell

    master

    Execute multiple shell commands simultaneously by passing them as a set of strings to the parallelshell command. All processes share the same stdout/stderr.

    Key Behaviors:

    • Automatic Cleanup: If any command exits with a non-zero exit status, all other running processes are automatically stopped.
    • Exit Code Propagation: The exit code of the first command that fails (non-zero exit status) is propagated as the final exit code.
    • Cross-Platform: Works on both Unix and Windows.
    • Windows Note: On Windows, you must use double-quotes around your commands to avoid argument parsing issues.

    Comparison to standard shell &:

    • Unlike cmd1 & cmd2, parallelshell waits until all commands have finished.
    • Unlike &, parallelshell will autokill sibling processes if one dies.
    • Unlike &, pressing Ctrl+C will exit all processes managed by parallelshell rather than just the foreground one.
    parallelshell "echo 1" "echo 2" "echo 3"
  2. Configure parallelshell CLI flags

    master

    The following flags are available when using the parallelshell command line interface:

    FlagLong FlagDescription
    -h--helpOutput usage information
    -v--verboseEnable verbose logging (shows command status and success/failure messages)
    -w--waitPrevents the tool from closing sibling processes when one command fails; it will wait for all processes to finish

    Note: Commands to be executed should be passed as positional arguments.

    parallelshell --verbose --wait "npm run build" "npm run test"
  3. Use the parallelshell CLI

    master

    The parallelshell CLI allows you to run multiple shell commands in parallel. By default, if any command fails (returns a non-zero exit code), the tool will attempt to close all other running sibling processes and exit with that error code. You can change this behavior using the --wait flag.

    Usage: parallelshell [options] <command1> <command2> ... <commandN>

    parallelshell "echo hello" "echo world"