[Bug fix] If the command exits with a code different from 0 then the task has failed #2

Closed
wants to merge 1 commit into
from

Projects

None yet

2 participants

@FGRibreau

No description provided.

@sindresorhus
Owner

Thanks :)

But I don't think this is needed?
It already checks for err which will only output when there are errors.

@FGRibreau

The check for "err" is clearly not enough.
For example try grunt-shell with "nodeunit test/*.js'" if a test fail the task won't fail but it should.

@sindresorhus
Owner

Works for me. Make sure you have set failOnError to true, it will not fail by default?

@FGRibreau

No, it doesn't fail with or without failOnError to true.

Try with:

shell: {
      nodeunit: {
        command: 'nodeunit test/**/*.js',
        stdout: true,
        stderr: true,
        failOnError:true,
        warnOnError: true
      }
    }

You won't see the

<WARN> Task "shell:nodeunit" failed. Use --force to continue. </WARN>

but you will with the fix. Falling on exit code != 0 is useful for notifying other grunt plugins that everything went fine or not.

@sindresorhus
Owner

Found the error. When stderr was true, it was taking precedence over failOnError and only logging the error.

Thanks for reporting this :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment