Sha256: 4764a162893c13c56b28cc8f75b523a793e89213a9e248760d308f0737030717

Contents?: true

Size: 653 Bytes

Versions: 1

Compression:

Stored size: 653 Bytes

Contents

# encoding: utf-8

require 'open3'

module Cliver
  module Which
    # Windows-specific implementation of Which
    # Required and mixed into Cliver::Which in windows environments
    module Windows
      # @param executable [String]
      # @return [nil,String] - path to found executable
      def which(executable)
        # `where` returns newline-separated files found on path, but doesn't
        # ensure that they are executable as commands.
        where, _ = Open3.capture2e('where', executable)
        where.split("\n").find do |found|
          next if found.empty?
          File.executable?(found)
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cliver-0.1.1 lib/cliver/which/windows.rb