Reputation: 55
I have a package.json
script for example npm run script1
and I have also private npm package which is added as a dependency in my project and this package has also scripts in package.json
and this script name script2
. I want that when I run npm run script1
then run automatically start script2. Is that possible?
Thank you.
Upvotes: 5
Views: 8053
Reputation: 414
Use npm explore command. For example, to run a test script from lodash after running eslint, add this script in your package.json file:
"scripts": {
"script1": "eslint . && npm explore lodash -- npm run test"
}
Then run it as:
npm run script1
Upvotes: 4
Reputation: 2186
Package.json
"scripts": {
"runbothscripts": "npm run script1 && npm run script2"
}
Should run both scripts for you if you execute it by doing npm run runbothscripts
.
If script2
would be in a different folders package.json you also first navigate to that folder by doing cd ./otherfolder && npm run script2
Upvotes: 9