run-await-run
v0.6.0
Published
Run command, await response, run command
Downloads
176
Readme
run-await-run
Run command, await response, run command
Inspired by start-server-and-test, just tiny compared!
Install
npm i -D run-await-run
Usage
Command to run NPM scripts in parallell, but second script waits for a response to begin. Usefull when first command starts up a server and second one should start afterwards.
run-await-run <run-first> <url> <run-second>
Example
{
"scripts": {
"server": "node ./server.js",
"test": "run-await-run server :8080 'playwright test'"
}
}
Options
position 1
(required): script one will run firstposition 2
(required): URL waiting to respondposition 3
(required): script two will run when url responds--get
(optional): fetches the URL with a GET request. Default is a HEAD request--timeout <number>
(optional): when to stop waiting in milliseconds. Default is 300000 milliseconds (5 minutes)--interval <number>
(optional): how often to check if URL responds in milliseconds. Default is 100 milliseconds
Handy features
auto add npm run
If position 1 or 3 matches a script in package.json, it will automaticly add npm run
. Meaning you can write e.g. server
instead of 'npm run server'
.
auto group arguments
Normally arguments must be wrapped by "
, but groups argument by '
. Meaning you can write 'npm run server'
instead of \"npm run server\"
.
auto add localhost
If position 2 is just :<port>
, it will add http://localhost:<port>/
. Meaning you can write :8080
instead of http://localhost:8080/