Sha256: 630291b2d72be092a5ebcf556f78019da51a3240aa29b37e421b546f20d99f61
Contents?: true
Size: 667 Bytes
Versions: 23
Compression:
Stored size: 667 Bytes
Contents
require 'pre-commit/checks/plugin' require 'shellwords' module PreCommit module Checks class Shell < Plugin private def execute(*args) options = args.last.is_a?(::Hash) ? args.pop : {} args = build_command(*args) execute_raw(args, options) end def build_command(*args) args.flatten.map do |arg| arg = arg.shellescape if arg != '|' && arg != '&&' && arg != '||' arg end.join(" ") end def execute_raw(command, options = {}) result = `#{command} 2>&1` $?.success? == (options.fetch(:success_status, true)) ? nil : result end end end end
Version data entries
23 entries across 23 versions & 1 rubygems