Sha256: ef43e3443e486e8a45c8be0a2573a4bb12976fb8b56771459439ac5f7ed41ab3
Contents?: true
Size: 791 Bytes
Versions: 19
Compression:
Stored size: 791 Bytes
Contents
require "open3" module GitCurate module Util # Runs the passed string as a system command, gathers any lines of output, stripped of # leading and trailing whitespace, and returns them as an array. def self.command_to_a(command) command_output(command).split($/).map(&:strip) end # Runs the passed string as a system command and returns its output. # If the command doesn't exit with 0 (success), then an error will be thrown, with the error # output as its message. def self.command_output(command) stdout_str, stderr_str, status = Open3.capture3(command) exit_status = status.exitstatus if exit_status != EXIT_SUCCESS raise SystemCommandError.new(stderr_str, exit_status) end stdout_str end end end
Version data entries
19 entries across 19 versions & 1 rubygems