如果脚本失败,NPM应该继续执行更多的脚本

我有我的package.json文件中的脚本,我在我的CMD执行npm运行量angular器

"scripts": { "postinstall": "bower install", "pretest": "npm install", "test": "karma start test/karma.conf.js", "test-single-run": "karma start test/karma.conf.js --single-run", "preupdate-webdriver": "npm install", "update-webdriver": "webdriver-manager update", "preprotractor": "npm run update-webdriver && node setUp.js", "protractor": "protractor test/protractor-conf.js", "postprotractor": "node tearDown.js", } 

如果我所有的e2etesting都通过了,那么npm会运行整个脚本 – 也就是我的tearDown.js。 但是,如果我的量angular器testing(“量angular器”:“量angular器testing/ protractor-conf.js”)失败,npm不会继续执行我的postprotractor文件(我需要tearDown.js,因为它closures我的后端) 。 有没有使npm运行整个脚本的任何解决scheme?

您应该在beforeLaunch和afterLaunch之间运行安装脚本和拆卸脚本作为量angular器的一部分,而不是npm。

如果由于某种原因,你绝对不想把它作为量angular器的一部分来运行,那你必须在量angular器的runLine( 例子 )或者围绕你的量angular器运行脚本包装一个脚本来改variablesangular器的exitCode为0。 不过,我强烈build议不要这样做,因为那样你只是掩盖了错误。