class PreCommit::Checks::Shell

Private Instance Methods

build_command(*args) click to toggle source
# File lib/pre-commit/checks/shell.rb, line 16
def build_command(*args)
  args.flatten.map do |arg|
    arg = arg.shellescape if arg != '|' && arg != '&&' && arg != '||'
    arg
  end.join(" ")
end
execute(*args) click to toggle source
# File lib/pre-commit/checks/shell.rb, line 10
def execute(*args)
  options = args.last.is_a?(::Hash) ? args.pop : {}
  args = build_command(*args)
  execute_raw(args, options)
end
execute_raw(command, options = {}) click to toggle source
# File lib/pre-commit/checks/shell.rb, line 23
def execute_raw(command, options = {})
  result = `#{command} 2>&1`
  $?.success? == (options.fetch(:success_status, true)) ? nil : result
end