ruby / rake

A make-like build utility for Ruby.

Home Page:https://ruby.github.io/rake

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Feature Request: shortcut to re-define task

amancevice opened this issue · comments

I think a nice feature would be to add a new DSL method to quickly re-define a task.

Something like:

# Define task
task :fizz do |t|
  puts "Old #{t.name}"
end

# Redefine task
task! :fizz do |t|
  puts "New #{t.name}"
end

# rake fizz
# => "New fizz"

Where task! is shorthand for

Rake::Task[:fizz].clear if Rake::Task.task_defined? :fizz
Rake::Task.define_task :fizz

I'm happy to open a PR for this if that sounds like something useful to others.

There's currently a simple way:

task(:fizz).clear.enhance do |t|
  puts "New #{t.name}"
end