问题
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