grunt icon indicating copy to clipboard operation
grunt copied to clipboard

Multitask marked as success when forced

Open deckar01 opened this issue 9 years ago • 0 comments

Issue: When force is enabled, multitasks are unconditionally marked as success, even if a child task fails with a warning.

Expected behavior: A multitask is only marked as success if all the child tasks were marked as success.

Use case: Forcing a task to be performed unconditionally after a multitask, then making it required without force enabled to defer failure. See https://github.com/floriangosse/grunt-force-task/issues/2#issuecomment-229729700. Related to #810.

Example:

module.exports = function (grunt) {
  'use strict';

  grunt.loadNpmTasks('grunt-force-task');

  grunt.registerTask('can-fail', function() {
    grunt.task.run('force:jasmine');
    grunt.task.run('istanbul_combine');
    grunt.task.run('jasmine-passed');
  });

  grunt.registerTask('test', function() {
    grunt.task.run('force:jasmine');
    grunt.task.run('istanbul_combine');
    grunt.task.run('jasmine-passed');
  });

  grunt.registerTask('jasmine-passed', function() {
    this.requires('jasmine');
  });
});

Since the jasmine task is a multitask, this.requires('jasmine') will never throw an error, because the jasmine task is being marked as a success. This is counter intuitive, because a child task like jasmine:cars can fail, generate a warning, but will be not marked as success.

deckar01 avatar Jun 30 '16 20:06 deckar01