Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
rjmackay opened this issue Jul 8, 2014 · 14 comments
Open

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

rjmackay opened this issue Jul 8, 2014 · 14 comments

Comments

@rjmackay
Copy link

rjmackay commented Jul 8, 2014

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
Copy link
Author

rjmackay commented Jul 8, 2014

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

@rjmackay
Copy link
Author

rjmackay commented Jul 8, 2014

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
Copy link
Owner

tschaub commented Jul 8, 2014

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
Copy link
Owner

tschaub commented Jul 8, 2014

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

@rjmackay
Copy link
Author

rjmackay commented Jul 8, 2014

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
Copy link

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
Copy link

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
Copy link

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
Copy link

+1

@lili21
Copy link

lili21 commented Mar 19, 2015

+1, same issue.

@dudewad
Copy link

dudewad commented Mar 24, 2015

+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
Copy link

blowsie commented Jun 17, 2015

@dudewad what you mat be experiencing is the issue mentioned in #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
Copy link

chemoish commented Jul 9, 2015

+1, experiencing it with eslint

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

@amalitsky
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants