rake icon indicating copy to clipboard operation
rake copied to clipboard

Feature Request: shortcut to re-define task

Open amancevice opened this issue 5 years ago • 1 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.

amancevice avatar May 30 '20 03:05 amancevice

There's currently a simple way:

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

konsolebox avatar May 12 '22 20:05 konsolebox