0.1.6 ā¢ Published 3 years ago
script-run v0.1.6
script-run š
Run arbitrary scripts in parallel alongside pretty output from their log files
$ npx script-run slow_script 'node dummy_script' logging_script:logging_script.log
ā “ tests/fixtures/slow_script (7.282s)
āŗ doing something slow....
almost done...
ā node tests/fixtures/dummy_script
ā tests/fixtures/logging_script (0.203s)
All commands succeeded.
Features
- Run any number of arbitrary shell scripts in parallel via child processes
- Stream live logs from each process
- Optionally provide a separate log file to tail
Installation
You can install script-run
globally via:
npm install -g script-run
# or
yarn global add script-run
or locally without including -g
or global
.
You can also run without manual installation, via npx:
npx script-run
Usage
Provide commands as positional arguments to run them in parallel. For example:
$ script-run 'git gc' 'echo hi'
ā git gc (0.804s)
ā echo hi
All commands succeeded.
This would run the git gc
and echo hi
commands in parallel subprocesses and stream any stdout/stderr to the console while they run.
If we have a script that logs to a known file, we can substitute the command output for that:
$ script-run logging_script:logging_script.log --persistent-output
ā tests/fixtures/logging_script (0.201s)
āŗ Output from tests/fixtures/logging_script.log:
My log line, i = 5
My log line, i = 6
My log line, i = 7
My log line, i = 8
My log line, i = 9
All commands succeeded.
Options
$ script-run --help
Options:
--help Show help [boolean]
--version Show version number [boolean]
--verbose Run with verbose logging [boolean] [default: false]
--log-lines Number of log lines to show at once per command
[number] [default: 5]
--color Whether to show colors in the terminal
[boolean] [default: true]
--timers Whether to show execution times for scripts
[boolean] [default: true]
--persistent-output Whether to persist output of log lines after command
success [boolean] [default: false]
Advanced
There's a js API exported which can be called from a wrapper script if desired, and aims to mimic the cli as closely as possible. Check the code to learn more (no documentation for this currently).