tschaub / grunt-newer

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

Explore recursively when dest is a directory #43

Closed oadam closed 9 years ago

oadam commented 10 years ago

Hello, I am using grunt-newer with grunt-ts, a typescript compiler wrapper. For this plugin, the dest parameter is the directory in which the compiled files should be written. For the moment, grunt-newer checks the mTime of this directory, which is not updated when grunt-ts is invoked and put files inside it. So grunt-ts is systematically called if the target directory happens to be older than one of the src files. Something inside me tells me that the guilty is grunt-ts not respecting grunt's src/dest conventions, but maybe this is just a missing feature of grunt-newer.

My question is simple : would you merge a pool request that would check if dest is a directory, and if so walk it recursively to get all the mTime of the children ?

tschaub commented 9 years ago

Hey @oadam - apologies for the delay in responding here. I think it would be nice to come up with a solution for tasks where the dest is a directory. But given many source files and a destination directory with many files, you still need to make some decisions.

One option would be to include all source files if any one of them is newer than any of the destination files. This would work for tasks that are using multiple files to create a single (or fewer) files.

Another option would be to only include the source files that are newer than the newest destination file. This would work for tasks that have a 1:1 mapping between input and output files (but don't use Grunt's conventions for src/dest file config).

How does the TypeScript compiler behave? Would it fit one of the above options?

tschaub commented 9 years ago

I'm going to fold this into #67 to track grunt-ts specific issues. It may be that we can come up with a general solution for tasks configured with dest directories, but I want to consolidate all the TypeScript issues first.