deostroll
deostroll

Reputation: 11995

how to preserve grunt task arguments when wrapping it

I am using the grunt-release plugin. Normally in a shell you use commands like grunt release, grunt release:minor, grunt release:major, etc. I am composing another task that wraps the release task:

grunt.registerTask('custom-release', ['task1', 'release', 'task2']);

Hence when you call grunt custom-release:major, is there any chance I can invoke my release task to get invoked as release:major?

Else am I forced to register tasks conforming to each of the grunt-release options?:

grunt.registerTask('custom-release-major', ['task1', 'release:major', 'task2']);

Upvotes: 1

Views: 28

Answers (1)

Zamboney
Zamboney

Reputation: 2010

try this:

grunt.registerTask('custom-release', 'my awesome custom-release', function(type) {
  switch(type){
    case 'major':
      grunt.task.run(['task1', 'release:major', 'task2'])
      break;
    case 'minor':
    default:
      grunt.task.run(['task1', 'release:minor', 'task2'])
      break;
  }
});

now you can use

  • grunt custom-release:major
  • grunt custom-release:minor
  • grunt custom-release

Upvotes: 1

Related Questions