suppose if i have some script in package.json like this
"scripts": { "a1": "first command", "a2": "second command", "a3": "third command", }
and if i want to run script a1 and a2 in the script a3 how can i do this? can this be possible? I am using
node version : v6.9.4
npm version : 4.3.0
i want to achieve something like this
"scripts": { "a1": "first command", "a2": "second command", "a3": "third command && a1 && a2", }
json file: To execute your Script, use the 'npm run <NAME-OF-YOUR-SCRIPT>' command. Some predefined aliases convert to npm run, like npm test or npm start, you can use them interchangeably.
Approach 1(npm-run all package): We can use the” npm-run all” package to run different scripts at the same time. First, we have to install the package itself by using the command. After installation of the package we have to navigate to the package.
A quick way of doing it is npm run start-watch & npm run wp-server . This will run the first command as a background thread. This works really well when one of the commands is not long running and does not need to be manually exited later.
Use npm run
inside the script. E.g.
"scripts": { "a1": "first command", "a2": "second command", "a3": "third command && npm run a1 && npm run a2", }
Running $ npm run a3
via the CLI will run the third command
(whatever that is), followed by a1
, then a2
.
However, if running $npm run a3
via the CLI is to only run a1
followed by a2
then:
"scripts": { "a1": "first command", "a2": "second command", "a3": "npm run a1 && npm run a2", }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With