Module: ExecCommand

Included in:
DbReplicator::Importer
Defined in:
lib/db_replicator/exec_command.rb

Instance Method Summary collapse

Instance Method Details

#exec_cmd(cmd) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
# File 'lib/db_replicator/exec_command.rb', line 3

def exec_cmd(cmd)
  Open3.popen2e(cmd) do |_, stdout_err, wait_thr|
    while line = stdout_err.gets
      puts line
    end

    exit_status = wait_thr.value
    unless exit_status.success?
      raise "Shell Error From: #{cmd}".colorize(:red)
    end
  end
end