-
-
Save Olgagr/01fd03538e575767aa72 to your computer and use it in GitHub Desktop.
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
module Heroku | |
module Rake | |
class Task | |
attr_accessor :name | |
def initialize(name) | |
@name = name | |
end | |
def self.[](name) | |
Heroku::Rake::Task.new(name) | |
end | |
def execute(options = {}) | |
cmd = "heroku run \"rake #{name}" | |
cmd += "; echo \\$?\"" | |
cmd += "#{options[:app] ? " --app #{options[:app]}" : ""}" | |
stdout = `#{cmd}` | |
$stdout.puts stdout.lines.to_a[0...-1] | |
exit_status = stdout.lines.to_a.last.chomp.to_i | |
raise "Heroku task #{name} failed with exit status #{exit_status}" unless exit_status == 0 | |
end | |
end | |
end | |
end | |
namespace :heroku | |
desc "Run example task on remote Heroku" | |
task "example_task" do | |
Heroku::Rake::Task["example_task"].execute({ :app => "example-app" }) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment