Conditional grunt task
Hi!
Are you need run a conditional grunt task? Maybe this tip can help you.
In this case, this script expect a grunt option named gui-version.
Ex: grunt publish --gui-version=VERSION
grunt.registerTask('publish', function() {
if(!grunt.option('gui-version')) {
grunt.fatal('ERROR: please, this task need that you send a param --gui-version=YOUR_VERSION');
} else {
grunt.task.run([
'handlebars'
, 'concat
, 'copy:components'
, 'uglify'
]);
}
});
You can use the same approach with params, and run:
grunt publish:myParam
grunt.registerTask('publish', function(myParam) {
if(!myParam) {
grunt.fatal('ERROR: i need a param');
} else {
grunt.task.run([
'handlebars'
, 'concat
, 'copy:components'
, 'uglify'
]);
}
});
This is it.
Written by Marcio Gasparotto
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Grunt
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#