Module: OpenStax::Aws::System

Defined in:
lib/openstax/aws/system.rb

Class Method Summary collapse

Class Method Details

.call(command, logger: nil, dry_run:) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/openstax/aws/system.rb', line 4

def self.call(command, logger: nil, dry_run:)
  logger&.info("**** DRY RUN ****") if dry_run
  logger&.info("Running: #{command}")

  if !dry_run
    Open3.popen2e(command) do |stdin, stdout_err, wait_thr|
      while line=stdout_err.gets do
        STDERR.puts(line)
      end

      exit_status = wait_thr.value.exitstatus
      exit(exit_status) if exit_status != 0
    end
  end
end