【问题标题】:How can I make a Grunt task fail if one of its sub tasks fail?如果 Grunt 任务的其中一个子任务失败,我怎样才能使 Grunt 任务失败?
【发布时间】:2013-06-07 11:49:43
【问题描述】:

我在 grunt 中有一个构建任务,如下所示:

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

问题是,即使 jshint 任务失败,uglify 任务也会运行,如果其中一个子任务失败,我怎样才能让“构建”任务终止?

【问题讨论】:

    标签: javascript node.js gruntjs jshint


    【解决方案1】:

    Grunt 中的默认行为是如果后续任务失败则不运行后续任务。因此,您必须在某处使用 force 选项。你是:

    1 - 在命令行传递--force

    2 - 在某处致电grunt.option( 'force', true );

    3 - 在你的 jshint 任务上设置 jshint force option

    请注意,在调用 grunt.option( 'force', true ); 的情况下,对于批处理的其余部分,它仍然是 true,而不仅仅是在设置它的任务内部。详见this questionthis question

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-07-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-06-25
      相关资源
      最近更新 更多