Created
June 16, 2016 12:15
-
-
Save jsborjesson/83fc4951723b699c016fced9b9b4e90c to your computer and use it in GitHub Desktop.
Programatically remove a task by name in Rake
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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