Class: ShellCommand

Inherits:
Object
  • Object
show all
Defined in:
rakelib/support/shell_command.rb

Class Method Summary collapse

Class Method Details

.run(command) ⇒ Object

runs shell command and prints output returns boolean depending on the success of the command



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'rakelib/support/shell_command.rb', line 6

def self.run(command)
  success = false
  old_sync = $stdout.sync
  $stdout.sync = true

  Open3.popen2e(command) do |_stdin, stdout_and_stderr, thread|
    while (line = stdout_and_stderr.gets)
      puts(line)
    end

    success = thread.value.success?
  end

  $stdout.sync = old_sync
  success
end