grunt-newer
grunt-newer copied to clipboard
Support full spectrum of ways to specify files in grunt config
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
For reference http://gruntjs.com/configuring-tasks#files
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
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.
See https://github.com/tschaub/grunt-newer/compare/moar-files-config for a potential fix. Still needs tests.
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..
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.
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'],
}
},
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.
+1
+1, same issue.
+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 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?
+1, experiencing it with eslint
"grunt-newer": "^1.1.1",
"grunt-eslint": "^16.0.0",
eslint: {
target: {
src: ['file1.js']
}
}
@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?