tschaub / grunt-newer

Configure Grunt tasks to run with newer files only.
https://npmjs.org/package/grunt-newer
MIT License
945 stars 61 forks source link

Fixed grunt newer failing to restore configuration #80

Open NullSoldier opened 9 years ago

NullSoldier commented 9 years ago

When grunt newer runs a task that fails, it will not restore the configuration leading to numerous silent bugs, especially when running newer on things like watch. Using override will solve this problem as we have no clean way to run post tasks once the main task has failed. This is basically re-creating try finally using force.

If you like this approach to solving the problem, I can create tests so we can get this merged in.

I got the idea for a force task from the comment here, https://github.com/gruntjs/grunt/issues/810#issuecomment-27363230

NullSoldier commented 9 years ago

I've been diving into the grunt source code, and i think there may be a way to run a task and know when it finishes by using grunt.task directly. I would like to look into it then open this PR again once I know if there is a better way or not.

diwu1989 commented 9 years ago

the force option is to enable the --force behavior built into grunt

from the grunt command line help

      --force, -f  A way to force your way past warnings. Want a suggestion?
                   Don't use this option, fix your code.
diwu1989 commented 9 years ago

pull request cleaned up @tschaub wanna review this?

tschaub commented 9 years ago

Can you provide an example that demonstrates the problem (and show how this change addresses it)? It's not clear looking at the code alone. An example repo or a gist with enough code to reproduce the issue would be great.

terite commented 8 years ago

It looks like @guncha uploaded repro steps - https://github.com/guncha/grunt-newer-conf-corruption/commit/1deb15b7bf64269639226f5ecf60d95a66f2bb22

@tschaub , are you able to reproduce using that test case?

Our team had to fork grunt-newer a while ago to fix this issue. We'd really like to delete our fork, but this is a blocking issue for us.