如果其中一个子任务失败,我该如何使Grunt任务失败? [英] How can I make a Grunt task fail if one of its sub tasks fail?

查看:79
本文介绍了如果其中一个子任务失败,我该如何使Grunt任务失败?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

问题在于即使jshint任务失败,uglify任务也会运行,我如何才能使'如果其中一个子任务失败,构建'任务终止?

解决方案

Grunt中的默认行为是不运行后续任务失败。所以你必须在某处使用强制选项。你可以是:
$ b $ 1在命令行中传递 - force



<2>调用 grunt.option('force',true); 某处



3 - 在您的jshint任务中设置 jshint force选项



请注意,在调用 grunt.option('force',true); 的情况下,该批次,而不仅仅是它所在的任务内。请参阅此问题这个问题了解详情。


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?

解决方案

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.

这篇关于如果其中一个子任务失败,我该如何使Grunt任务失败?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆