Created
July 2, 2019 13:09
-
-
Save a-suenami/d835db18976126249a384b9639c3099d to your computer and use it in GitHub Desktop.
Execute local ruby script on Heroku.
This file contains 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
#!/usr/bin/env ruby | |
# | |
# Usage: | |
# irbify.rb script.rb | heroku run rails console --app=my-app | |
# | |
# Why eval and not piping directly? Piping directly would run all lines even if previous line was an invalid statement. | |
# | |
script_name = ARGV[0] | |
script = File.open(script_name, 'r').read | |
if File.readable? script_name | |
puts 'eval ' + script.dump + '; exit' | |
exit 0 | |
else | |
puts "Cannot read/open '#{ARGV[0]}'" | |
exit 1 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment