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

Support full spectrum of ways to specify files in grunt config #54

Open rjmackay opened 10 years ago

rjmackay commented 10 years ago

I found grunt-newer worked if I did

        // JSHint checking of the JS app files
        jshint :
        {
            all : {
                files : ['Gruntfile.js', 'media/js/app/**/*.js'],
            },
            options : {
                jshintrc : '.jshintrc'
            }
        },

but not for

        // JSHint checking of the JS app files
        jshint :
        {
            all : ['Gruntfile.js', 'media/js/app/**/*.js'],
            options : {
                jshintrc : '.jshintrc'
            }
        },

It seems to only understand one syntax for files but grunt supports multiple ways of specifying.

Refs #39

rjmackay commented 10 years ago

For reference http://gruntjs.com/configuring-tasks#files

rjmackay commented 10 years ago

I suspect part of the problem is that grunt-newer parses files out of the config (https://github.com/tschaub/grunt-newer/blob/master/tasks/newer.js#L64) rather than using this.files from inside a task http://gruntjs.com/api/inside-tasks#this.files

tschaub commented 10 years ago

Thanks for the ticket. Keep in mind that this.files can only be used within a task that has a "files config" (of any flavor). The newer task itself does not have a files config (so this.files is undefined within that task). The way the newer task works is to use Grunt's own function for normalizing multi-task files.

The issue above is that the value itself is an array instead of a config object. This condition should be checked when the task config is originally accessed. The code currently only works with config objects. It needs to account for array or string values as well.

tschaub commented 10 years ago

See https://github.com/tschaub/grunt-newer/compare/moar-files-config for a potential fix. Still needs tests.

rjmackay commented 10 years ago

This condition should be checked when the task config is originally accessed. The code currently only works with config objects. It needs to account for array or string values as well.

Fair enough. I haven't read the code in detail, just figured that grunt must be doing that itself somewhere too..

DomDerrien commented 9 years ago

FYI, I've applied the proposed patch and I get when one file is updated:

Running "newer:jshint" (newer) task

Running "newer:jshint:files" (newer) task

Running "jshint:files" (jshint) task
Warning: Cannot use 'in' operator to search for 'src' in Gruntfile.js Use --force to continue.

Without the patch, it would go over all files every time, files updated or not.

mquintal commented 9 years ago

I'd the same issue and I solved it using src instead of files. Analyzing newer source file (version 0.7.0) I realized that I can use the following structure.

jshint :
        {
            all : {
                src : ['filesxxxx.js', 'media/js/app/**/*.js'],
            }
        },
DomDerrien commented 9 years ago

I confirm @mquintal option: few days ago, I rewrote all my settings for jsbeautifier, jshint, stylud, copy, uncss, and jsdoc with the src: [...] pattern and grunt-newer work as expected.

djmccormick commented 9 years ago

+1

lili21 commented 9 years ago

+1, same issue.

dudewad commented 9 years ago

+1 This issue has been open for 9 months. Do we have an ETA? This task is literally useless without this patch for me. FYI, neither the "files" or the "src" approaches are working for me. I am experiencing it via the assemble module, among others.

blowsie commented 9 years ago

@dudewad what you mat be experiencing is the issue mentioned in https://github.com/tschaub/grunt-newer/issues/39 (expand:true causes the plugin top fail) @tschaub could you confirm that using expand:true causes an issue with this plugin, and highlight the cause of the issue within the code so I can try and submit a PR?

chemoish commented 9 years ago

+1, experiencing it with eslint

"grunt-newer": "^1.1.1",
"grunt-eslint": "^16.0.0",
eslint: {
  target: {
    src: ['file1.js']
  }
}
amalitsky commented 8 years ago

@tschaub, why the suggested fix (https://github.com/tschaub/grunt-newer/compare/moar-files-config) hasn't been merged yet? Do you wait for someone with tested PR?