Let's say I have
"scripts": {
"pre-build": "echo \"Welcome\" && exit 1",
"build_logic": "start cmd.exe @cmd /k \"yo esri-appbuilder-js:widget && exit 1\"",
"post_build": "start C:\\WebAppBuilderForArcGIS\\startupShortcut",
"exit" : "start cmd.exe @cmd /k \"echo \"goodbye\" && exit 1\""
},
What NPM command can I run to let all of these scripts launch sequentially. When I use pre/post fixing they launch sequentially but they don't wait for the parent script to finish before executing. I am assuming the only solution is like: How do I get Gulp tasks to fire sequentially when firing shell commands in an async.series helper function? ? I know this can be done with Gulp but I would like to stick with NPM for now to explore its capabilities. Thanks for any help!
Invoke these scripts via npm run
and chain them with double ampersand &&
:
npm run pre-build && npm run build_logic && npm run post_build && npm run exit
You can either run the above command directly on the command line, or you can set it as another script like this:
"scripts": {
...
"build": "npm run pre-build && npm run build_logic && npm run post_build && npm run exit",
}
And then run the whole list via npm run build
.
Explanation:
&&
(double ampersand) for sequential execution.&
(single ampersand) for parallel execution. Test carefully as commands earlier in the list may be run in background and you may potentially lose the output including any error messages (depending on your platform/shell).