Run one rake task after another completes

Viewed 2795

I'm trying to split down a rake task that i have,

What im wanting to do is after the rake task completes, It fires off another rake task.

Is this possible and if so how?

2 Answers

Passing a task as an argument to enhance causes it to run BEFORE the task you are "enhancing".

Rake::Task["task_A"].enhance(["task_B"])
# Runs task_B
# Runs task_A

Passing a task to enhance in a block causes it to run AFTER the task you are "enhancing".

Rake::Task["task_A"].enhance do
  Rake::Task["task_B"].execute
end
# Runs task_A
# Runs task_B

Reference: Rake Task enhance Method Explained

Related