I have a grunt task that looks at options with grunt.option(\'foo\')
. If I\'m calling this task from grunt.task.run(\'my-task\')
, how can I change thos
In addition to @Alessandro Pezzato
Gruntfile.js:
grunt.registerTask('build', ['clean:dist', 'assemble', 'compass:dist', 'cssmin', 'copy:main']);
grunt.registerTask('build-prod', 'Build with production options', function () {
grunt.config.set('assemble.options.production', true);
grunt.task.run('build');
});
grunt.registerTask('build-live', 'Build with production options', function () {
grunt.option('assemble.options.production', false);
grunt.task.run('build');
});
Now you can run
$ grunt build-prod
-OR-
$ grunt build-live
They will both do the full task 'build' and respectively pass a value to one of the options of assemble, namely production 'true' or 'false'.
In addition to illustrate the assemble example a bit more:
In assemble you have the option to add a {{#if production}}do this on production{{else}}do this not non production{{/if}}