panthro
panthro

Reputation: 24061

Running a task from my custom task?

I am creating a custom grunt task:

grunt.registerTask('my-task', 'Do something', function() {

From inside this task I wish to run a grunts copy task, passing different destinations each time.

How can I run a task from inside my custom task passing different vars each time?

Upvotes: 0

Views: 38

Answers (1)

theaccordance
theaccordance

Reputation: 889

If you're writing a custom task, you can take advantage of the API that grunt exposes. You can run tasks within your custom task using grunt.task.run();

function myCustomTask(grunt) {
  grunt.log.ok('This is my custom task.');
  grunt.task.run('copy');
}

grunt.registerTask('my-task', 'Do something', myCustomTask);

You can learn more about running tasks within your custom task by reading this API Documentation

Upvotes: 1

Related Questions