Method: Pod::Executable.execute_command
- Defined in:
- lib/cocoapods/executable.rb
.execute_command(executable, command, raise_on_failure = true) ⇒ String
Executes the given command displaying it if in verbose mode.
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/cocoapods/executable.rb', line 48 def self.execute_command(executable, command, raise_on_failure = true) bin = which!(executable) command = command.map(&:to_s) if File.basename(bin) == 'tar.exe' # Tar on Windows needs --force-local command.push('--force-local') end full_command = "#{bin} #{command.join(' ')}" if Config.instance.verbose? UI.("$ #{full_command}") stdout = Indenter.new(STDOUT) stderr = Indenter.new(STDERR) else stdout = Indenter.new stderr = Indenter.new end status = popen3(bin, command, stdout, stderr) stdout = stdout.join stderr = stderr.join output = stdout + stderr unless status.success? if raise_on_failure raise Informative, "#{full_command}\n\n#{output}" else UI.("[!] Failed: #{full_command}".red) end end output end |