How to return some value from a rake task

How can I return some value from a task Rakein ruby.

Code example:

namespace tasks
    task task1: :environment do |task|
      log = "Running task"
      puts log
      log << "Done"
      return log # suggest how to do this
    end
end

I would do a rake as: Rake::Task['tasks:task1'].invoke. How to get the return value in a variable as follows:

result = Rake::Task['tasks:task1'].invoke
+4
source share
1 answer

You can exit the rake task with the code, and then check that with $?

But perhaps a rake might not be the best tool for this job.

0
source

Source: https://habr.com/ru/post/1673804/


All Articles