Can I overwrite a dependency without doing repo a fork?

Asked 2 years ago

I have a rake task that calls another rake task as a dependency. I want to overwrite what the dependency task does without having to fork the original repository and change the dependency task. Is this possible?

Gideon Pacheco

Friday, June 17, 2022

Yes. You can use the overwrite method in your Rakefile. For example, let's say you have a task called update_data that's set to run every day. But you only want it to run if the data.csv file has been updated. You can use the overwrite method to make this happen: overwrite update_data => :data do |t| t.need_update = File.exist?('data.csv') && File.mtime('data.csv') > t.updated_at end Now, when you run the update_data task, it will only run if the data.csv file has been updated since the last time the task was run.





Write an answer...

Cancel

Please follow our  Community Guidelines

Can't find what you're looking for?