How can I make a Grunt task fail if one of its sub tasks fail?

久未见 提交于 2019-12-12 19:42:29

问题


I have a build task in grunt, which looks like this:

grunt.registerTask("build", ["jshint", "uglify"]);

The problem is that the uglify task runs even if the jshint task fails, how can I make the 'build' task terminate if one of it's sub tasks fails?


回答1:


The default behavior in Grunt is to not run subsequent tasks if one fails. So you must be using the force option somewhere. You are either:

1 - passing --force on the command line

2 - calling grunt.option( 'force', true ); somewhere

3 - have the jshint force option set on your jshint task

Note that in the case of calling grunt.option( 'force', true );, it remains true for the remainder of the batch, not just inside the task where it was set. see this question and this question for details.



来源:https://stackoverflow.com/questions/16983428/how-can-i-make-a-grunt-task-fail-if-one-of-its-sub-tasks-fail

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!