Sha256: 0693334ef30cd1d9de5d4414ae3150e241ebe292c41b7cbe8856d002e934d63d

Contents?: true

Size: 638 Bytes

Versions: 3

Compression:

Stored size: 638 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
      # Posix adapter to `which`
      # @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

3 entries across 3 versions & 1 rubygems

Version Path
cliver-0.1.5 lib/cliver/which/posix.rb
cliver-0.1.4 lib/cliver/which/posix.rb
cliver-0.1.3 lib/cliver/which/posix.rb