Skip to content

Commit

Permalink
Merge pull request #58 from heroku/app-run-fixes
Browse files Browse the repository at this point in the history
app.run fixes
  • Loading branch information
schneems authored Mar 8, 2019
2 parents a89fbfa + bda6d9b commit ac10db2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/hatchet/app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,12 @@ def add_database(plan_name = 'heroku-postgresql:dev', match_val = "HEROKU_POSTGR
# but programatically and with more control
def run(cmd_type, command = nil, options = {}, &block)
command = cmd_type.to_s if command.nil?
heroku_options = (options.delete(:heroku) || {}).map {|k,v| "--#{k.to_s.shellescape}=#{v.to_s.shellescape}"}.join(" ")
heroku_command = "heroku run #{command.to_s.shellescape} -a #{name} #{ heroku_options }"
heroku_options = (options.delete(:heroku) || {}).map do |k,v|
arg = "--#{k.to_s.shellescape}"
arg << "=#{v.to_s.shellescape}" unless v.nil?
arg
end.join(" ")
heroku_command = "heroku run -a #{name} #{heroku_options} --exit-code -- #{command}"
bundle_exec do
if block_given?
ReplRunner.new(cmd_type, heroku_command, options).run(&block)
Expand Down
8 changes: 8 additions & 0 deletions test/hatchet/app_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,12 @@ def app.push_with_retry!; end # Don't actually deploy
end
end
end

def test_run
app = Hatchet::GitApp.new("default_ruby")
app.deploy do
assert_match /ls: cannot access 'foo bar #baz': No such file or directory\s+Gemfile/, app.run("ls -a Gemfile 'foo bar #baz'")
assert (0 != $?.exitstatus) # $? is from the app.run use of backticks
end
end
end

0 comments on commit ac10db2

Please sign in to comment.