Skip to content

Instantly share code, notes, and snippets.

@jsborjesson
Created June 16, 2016 12:15
Show Gist options
  • Save jsborjesson/83fc4951723b699c016fced9b9b4e90c to your computer and use it in GitHub Desktop.
Save jsborjesson/83fc4951723b699c016fced9b9b4e90c to your computer and use it in GitHub Desktop.
Programatically remove a task by name in Rake
# Monkeypatch to remove tasks
module Rake
def self.remove_task(task_name)
Rake.application.instance_variable_get('@tasks').delete(task_name.to_s)
end
end
# Example: disable all of the tasks in the db namespace
namespace :db do |ns|
ns.tasks.each do |task|
Rake.remove_task(task)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment