问题描述
假设我已经
"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\""
},
我可以运行什么NPM命令让所有人这些脚本按顺序启动。当我使用前/后修复时,它们按顺序启动,但它们不会在执行前等待父脚本完成。我假设唯一的解决方案是:?我知道这可以用Gulp完成,但我现在想坚持使用NPM来探索它的功能。感谢您的帮助!
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!
推荐答案
通过npm run调用这些脚本并用双&符号链接它们 &&
:
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
说明:
- 使用
&&
(双&符号)进行顺序执行。 - 使用
&
(单个&符号)进行并行执行。
- Use
&&
(double ampersand) for sequential execution. - Use
&
(single ampersand) for parallel execution.
这篇关于按顺序运行NPM脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!