Class: Binpkgbot::Tasks::Run

Inherits:
Base
  • Object
show all
Includes:
Concern::Emerge
Defined in:
lib/binpkgbot/tasks/run.rb

Instance Attribute Summary

Attributes inherited from Base

#config, #options

Instance Method Summary collapse

Methods included from Concern::Emerge

#emerge, #emerge_runner

Methods inherited from Base

#execute, #initialize

Constructor Details

This class inherits a constructor from Binpkgbot::Tasks::Base

Instance Method Details

#runObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/binpkgbot/tasks/run.rb', line 9

def run
  script = [*@options[:script],*@options[:scripts]].join("\n")
  if @options[:host]
    puts script.each_line.map.with_index { |_,i| "#{(i.zero? ? "$ " : "  ")}#{_}" }.join(?\n)
    r,w = IO.pipe
    w.puts script
    pid = spawn('bash', in: r)
    r.close
    w.close
    _, status = Process.waitpid2(pid)
    if !status.success?
      raise "host run failed #{status.inspect}, #{command_line.inspect}"
    end
  else
    emerge_runner(script, ephemeral: @options.key?(:persist) ? !@options[:persist] : false)
  end
end