Module: BuildpackSupport::Shell

Included in:
Component::Downloads, Component::VersionedDownloads
Defined in:
lib/buildpack_support/shell.rb

Overview

A mixin that provides a shell() command

Instance Method Summary collapse

Instance Method Details

#shell(command) ⇒ Void

A system()-like command that ensure that the execution fails if the command returns a non-zero exit code

Parameters:

  • command (String)

    the command to run

Returns:

  • (Void)


28
29
30
31
32
33
34
35
36
37
38
# File 'lib/buildpack_support/shell.rb', line 28

def shell(command)
  Open3.popen3(command) do |_stdin, stdout, stderr, wait_thr|
    if wait_thr.value != 0
      puts "\nCommand '#{command}' has failed"
      puts "STDOUT: #{stdout.gets}"
      puts "STDERR: #{stderr.gets}"

      fail
    end
  end
end