Giter VIP home page Giter VIP logo

Comments (9)

floriangosse avatar floriangosse commented on June 11, 2024

Why do you want that the following tasks should be executed after one forced task failed? You can replace force:your-task with your-task and it will fail there.

from grunt-force-task.

kylezeeuwen avatar kylezeeuwen commented on June 11, 2024

In my case I want the following tasks to execute because the following task is a clean up task that must run, regardless of whether your-task passes or fails.

grunt-force-task allows the following task to always run, which is good. But if I use force:your-task the grunt process exit code is always 0, regardless of whether your-task passes or fails. I need the grunt process exit code to match the pass/fail status of your-task.

from grunt-force-task.

floriangosse avatar floriangosse commented on June 11, 2024

If I didn't overlook anything you need to add an extra task for it. And I think this is not the task of grunt-force-task.

from grunt-force-task.

deckar01 avatar deckar01 commented on June 11, 2024

@kylezeeuwen That solution doesn't seem to be working for me. I am using jasmine to run unit tests, and need to generate the coverage report even if the tests fail. Your solution just causes an additional task to output the warning without actually failing the task.

@floriangosse The issue seems to be that resetting force in the post task can't change the fact that the task gets stored as a success. Listing the task as a dependency without the force prefix resolves to a task that grunt thinks succeeded. It would be nice if this library caught the task exception instead of setting the force option so that the underlying task would not get marked as a success.

Update: It is not working for me, because I am forcing a multitask. Although the subtask it not added to the success list, the parent multitask still is.

grunt.loadNpmTasks('grunt-force-task');
grunt.loadNpmTasks('grunt-contrib-jasmine');
grunt.loadNpmTasks('grunt-istanbul-combine');

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');
});

My real tasks pass through the subtask which causes the requires statement to more specifically target the task that actually failed (so it works as long as the target is not a multitask).

I think this is a grunt bug. Even if force is enabled, a multitask should not be marked as success if a child task fails.

from grunt-force-task.

kylezeeuwen avatar kylezeeuwen commented on June 11, 2024

Hi @floriangosse , sorry for the delay. I agree that "this is not the task of grunt-force-task so am happy to close the issue.

I raised the issue so we can consider if it is worth documenting the "grunt success/fail behaviour" when using grunt-force-task, and to point users at solutions if they have use cases like the one I describe

from grunt-force-task.

kylezeeuwen avatar kylezeeuwen commented on June 11, 2024

Hi @deckar01 , in my use case I was interested in the exit code of the grunt process. I would like to know, in your scenario, whether you are getting a 0 or non-zero exit code when jasmine fails.

Apologies if this is obvious but to quickyl review exit code checking in a *nix environment

Kyles-MacBook-Pro:~ kyle$ true
Kyles-MacBook-Pro:~ kyle$ echo $?
0

Kyles-MacBook-Pro:~ kyle$ false
Kyles-MacBook-Pro:~ kyle$ echo $?
1

Kyles-MacBook-Pro:~ kyle$ grunt test
Kyles-MacBook-Pro:~ kyle$ echo $?
<WHAT IS THE VALUE HERE> ??

from grunt-force-task.

deckar01 avatar deckar01 commented on June 11, 2024
  • With grunt-force alone I am getting a 0 exit code.
  • If I use your fix on a single task I get a non-zero exit code. 👌
  • If I use your fix on a multitask I get a 0 exit code 😞 (because grunt marked the multitask as a success).

I am kicking off the grunt task with an npm script which produces a nice long error message when the exit code is non-zero.

from grunt-force-task.

kylezeeuwen avatar kylezeeuwen commented on June 11, 2024

Ok I understand, interesting ! And unfortunate :( I'll have a play update the official docs (stack overflow) .

from grunt-force-task.

deckar01 avatar deckar01 commented on June 11, 2024

FWIW I moved my "delayed failure" logic into the npm script and stopped using grunt-force-task.

grunt test; STATUS=$?; grunt istanbul_combine; exit $STATUS

Not ideal, but not unbearable.

from grunt-force-task.

Related Issues (2)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.