Anurag Tiwari
1 min readNov 8, 2019

--

If anyone is facing an issue where the after hook get executed before the main task

use the `at_exit` block provided by ruby. This ensures the after_hook runs after the main task has executed.

task :before_hook do
puts "Before hook"
end
task :after_hook do
at_exit do
puts "After hook"
end
end
tasks = Rake.application.tasks
tasks.each do |task|
next if [Rake::Task['before_hook'],
Rake::Task['after_hook']].include?(task)
task.enhance([:before_hook, :after_hook])
end

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Anurag Tiwari
Anurag Tiwari

Written by Anurag Tiwari

Senior Software Engineer@ HackerRank

No responses yet

Write a response