假设我有
"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 命令来让所有这些脚本按顺序启动。当我使用前/后修复时,它们会按顺序启动,但不会等待父脚本完成后再执行。我假设唯一的解决方案是:How do I get Gulp tasks to fire sequentially when firing shell commands in an async.series helper function? ?我知道这可以通过 Gulp 完成,但我现在想坚持使用 NPM 来探索它的功能。感谢您的帮助!
最佳答案
通过 npm run 调用这些脚本并用双 & 符号链接(symbolic link)它们&&
:
npm run pre-build && npm run build_logic && npm run post_build && npm run exit
解释:
- 使用
&&
(双和号)进行顺序执行。 - 使用
&
(单与号)进行并行执行。
关于javascript - 顺序运行 NPM 脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39172536/