grunt-newer icon indicating copy to clipboard operation
grunt-newer copied to clipboard

Support full spectrum of ways to specify files in grunt config

Open rjmackay opened this issue 10 years ago • 14 comments

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 avatar Jul 08 '14 01:07 rjmackay

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

rjmackay avatar Jul 08 '14 01:07 rjmackay

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

rjmackay avatar Jul 08 '14 01:07 rjmackay

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 avatar Jul 08 '14 02:07 tschaub

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

tschaub avatar Jul 08 '14 02:07 tschaub

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..

rjmackay avatar Jul 08 '14 02:07 rjmackay

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.

DomDerrien avatar Sep 19 '14 12:09 DomDerrien

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'],
            }
        },

mquintal avatar Oct 10 '14 10:10 mquintal

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.

DomDerrien avatar Oct 10 '14 11:10 DomDerrien

+1

djmccormick avatar Nov 12 '14 15:11 djmccormick

+1, same issue.

lili21 avatar Mar 19 '15 03:03 lili21

+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.

dudewad avatar Mar 24 '15 17:03 dudewad

@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?

blowsie avatar Jun 17 '15 13:06 blowsie

+1, experiencing it with eslint

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

chemoish avatar Jul 09 '15 03:07 chemoish

@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?

amalitsky avatar Sep 16 '15 00:09 amalitsky