Sha256: b6b967182f8c221d3005650f71b3e66f0cf2234aa4a214af0628982763eb6758

Contents?: true

Size: 605 Bytes

Versions: 1

Compression:

Stored size: 605 Bytes

Contents

# encoding: utf-8
require 'shellwords'

module Cliver
  module Which
    # Posix implementation of Which
    # Required and mixed into Cliver::Which in posix environments
    module Posix
      # @param executable [String]
      # @return [nil,String] - path to found executable
      def which(executable)
        which = `which #{Shellwords.escape executable} 2>&1`
        executable_path = which.chomp
        return nil if executable_path.empty?
        executable_path
      rescue Errno::ENOENT
        raise '"which" must be on your path to use Cliver on this system.'
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cliver-0.1.2 lib/cliver/which/posix.rb