lib/shopify_cli/context.rb
# Checks if the given command exists in the system
#
# #### Parameters
# - `cmd`: The command to test
#
# #### Returns
# The path of the executable if it is found
#
# @todo This is currently a duplicate of CLI::Kit::System.which() - we should make that method public when we make
#       Kit changes and make this a wrapper instead.
Checks if the given command exists in the system
Parameters
`cmd`: The command to test

Returns
The path of the executable if it is found
Checks if the given command exists in the system Parameters ` cmd ` : The command to test Returns The path of the executable if it is found
def which(cmd)
      exts = ENV["PATHEXT"] ? ENV["PATHEXT"].split(";") : [""]
      ENV["PATH"].split(File::PATH_SEPARATOR).each do |path|
        exts.each do |ext|
          exe = File.join(File.expand_path(path), "#{cmd}#{ext}")
          return exe if File.executable?(exe) && !File.directory?(exe)
        end
      end
      nil
    end
def which ( cmd ) exts = ENV [ "PATHEXT" ] ? ENV [ "PATHEXT" ] . split ( ";" ) : [ "" ] ENV [ "PATH" ] . split ( File :: PATH_SEPARATOR ) . each do | path | exts . each do | ext | exe = File . join ( File . expand_path ( path ) , "#{cmd}#{ext}" ) return exe if File . executable? ( exe ) && ! File . directory? ( exe ) end end nil end
Checks if the given command exists in the system
 Parameters
 `cmd`: The command to test
Checks if the given command exists in the system Parameters ` cmd ` : The command to test
cmd
todo
This is currently a duplicate of CLI::Kit::System.which() - we should make that method public when we make Kit changes and make this a wrapper instead.
This is currently a duplicate of CLI :: Kit :: System . which () - we should make that method public when we make Kit changes and make this a wrapper instead .