Grunt is removing the helpers and this already happened in grunt-contrib.
However I have a Grunt file relying on some custom tasks calling some of those helpers. Without helpers it breaks. I am just wondering what should be the correct way to replace those.
I get it will be by calling the tasks directly in some way but I am not sure how. An example would help a lot since Grunt documentation is not updated yet.
Thanks.
Grunt is removing the helpers and this already happened in grunt-contrib.
However I have a Grunt file relying on some custom tasks calling some of those helpers. Without helpers it breaks. I am just wondering what should be the correct way to replace those.
I get it will be by calling the tasks directly in some way but I am not sure how. An example would help a lot since Grunt documentation is not updated yet.
Thanks.
Share Improve this question asked Sep 11, 2012 at 22:25 GriffonRLGriffonRL 2,2882 gold badges18 silver badges13 bronze badges1 Answer
Reset to default 9Ok after some research and the help of the maintainers of grunt-contrib, I rewrote that task I have:
grunt.registerMultiTask('multicss', 'Minify CSS files in a folder', function() {
grunt.file.expandFiles(this.data).forEach(function(file) {
var minified = grunt.helper("mincss", grunt.file.read(file));
grunt.file.write(file, minified);
grunt.log.writeln("Minified CSS "+file);
});
});
Into this:
grunt.registerMultiTask('multicss', 'Minify CSS files in a folder', function() {
var count = 0;
grunt.file.expandFiles(this.data).forEach(function(file) {
var property = 'mincss.css'+count+'.files';
var value = {};
value[file] = file;
grunt.config(property, value);
grunt.log.writeln("Minifying CSS "+file);
count++;
});
grunt.task.run('mincss');
});
No other change needed in the config file. The new piece of code makes use of the task itself instead of the helper that is gone.
This might not be the best approach and Grunt 0.4.0 might change the game again, but it does work right now with Grunt 0.3.15 and grunt-contrib 0.2.