tschaub / grunt-newer

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

Issue when src and dest is the same path #24

Closed rpominov closed 10 years ago

rpominov commented 10 years ago

Hi, thanks for your great plugin, it very helpful!

I notice small issue: it seems to doesn't work when task configured the way when source and destination is the same file.

Example:

concat: {
  banner: {
    options: {
      banner: "some banner ..."
    },
    expand: true,
    flatten: false,
    cwd: 'dist',
    src: '*.js',
    dest: 'dist'
  }
}

I use grunt-contrib-concat to add banners (I know it not very smart, but works). When I try to run concat task, configured like this, through newer it always handle zero files.

P.S. Sory for my bad english.

eirikhm commented 10 years ago

I can confirm this. It cannot find any "newer files" when I'm using this with grunt-typescript, but as soon as I change dst everything works as it should.

tschaub commented 10 years ago

This is a known limitation. It is not possible for source files to be newer than destination files when the source and destination are the same file. An alternative to processing files in place is to have each task produce a new set of files. Hope that makes sense.

russelldavis commented 10 years ago

@tschaub Couldn't you address this by treating these tasks (where src and dest are the same) like tasks that don't have a dest at all, i.e., compare to the timestamp of when the task was last run?

tschaub commented 10 years ago

Indeed @russelldavis

tschaub commented 10 years ago

@pozadi I think 3e49f4897cb5170d81c9028bc4e5c922f77cbeb5 should address your issue. If you're able to test out the same branch, let me know if this works as expected.

rpominov commented 10 years ago

Yes, it works great. Thank you.

rpominov commented 10 years ago

Sorry for closing, didn't realize that it is PR now :)

tschaub commented 10 years ago

Thanks for testing @pozadi (and thanks for the good suggestion @russelldavis).

Published as grunt-newer@0.6.1.