npm-run-all
npm-run-all copied to clipboard
Feature request - Delay option.
Feature request for a flag to specify delay when two or more tasks should run in parallel. For case when two or more tasks has to be running simultaneously, but there has to be a delay before starting task number two.
Example: run postcss:dev
script, wait for a 1000 ms and run start
script. Then, keep both running in parallel.
"postcss:dev": "postcss --config postcss.config.js -o css/styles.css css/**/*.postcss --map --watch",
"start": "react-scripts-ts start",
"start:dev": "sh -ac '. ./.env.development;' && npm-run-all -p postcss:dev --delay=1000 start"
Without the delay, app will reload before the postcss gets compiled which leads to styles not loaded properly.
Is there some progress on this feature?
If you need a delay, you should use delay-cli
To the original example, here is my preferred solution:
- have a
prep-build
script that does your initial CSS build - have a separate
watch
script that watches for changes and rebuilds your CSS based on that - have your
dev
script run theprep-build
script, and then run all yourwatch
scripts and your development server in parallel
Example at https://github.com/TehShrike/memorize-text-app/blob/3c5126f70b8485541f6d6e69dda6ec496fafa1b4/package.json#L12
Thank you, but i'm using it differently.
"pretest:integration": "webdriver-manager update",
"test:integration": "run-p test:integration:*",
"test:integration:student": "run-s test:integration:student:*",
"test:integration:student:desktop": "ng e2e student-integration --webdriver-update false",
"test:integration:student:tablet": "ng e2e student-integration --webdriver-update false --protractorConfig test/integration/protractor-tablet.conf.js",
"test:integration:student:mobile": "ng e2e student-integration --webdriver-update false --protractorConfig test/integration/protractor-mobile.conf.js",
"test:integration:teacher": "ng e2e teacher-integration --webdriver-update false",
"test:integration:preview": "ng e2e preview-integration --webdriver-update false",
It would be nice to set an interval between parallel jobs. Do you think thats possible?
If you're setting a delay between them, then they're not running in parallel :-x
Well, that's just not true. For example, start a server listening on a port and wait a few beats for the server to start. Then, start a client which connects to that server over the port and has a conversation. If the client starts before the server (possible due to variations in process startup), then the client will crash with no server endpoint. Solving this problem by waiting for a file or sleeping until the port is up and being used is the current best method (I use lsof -ti tcp:<port>
for this purpose). A delay would be nicer. Or, for my purposes a way to specify if a port is active, but that's not the original request (for a delay).
These two processes are definitely running in parallel, they just need a staggered start.
I would recommend making a CLI script that polls for a port to be open, that exits with a code 0 once the port is open, or exits with a non-0 exit code after some timeout period. Then you can run your client like poll-for-port --port=8080 --timeout=5000 && node ./my-client-test-thingy.js
This functionality seems out of scope for npm-run-all
I have often recommended wait-on package.
This shouldn't be part of npm-run-all
. There's already the native sleep
on most OSs and you can use delay-cli
if you want a cross-platform version. Or even the excellent wait-on
, which sounds perfect for your scope instead of waiting an arbitrary time.