Method: CommandKit::Env::Path#find_command

Defined in:
lib/command_kit/env/path.rb

#find_command(name) ⇒ String?

Searches for the command in #path_dirs.

Parameters:

  • name (String, Symbol)

    The command name.

Returns:

  • (String, nil)

    The absolute path to the executable file, or nil if the command could not be found in any of the #path_dirs.



50
51
52
53
54
55
56
57
58
59
60
# File 'lib/command_kit/env/path.rb', line 50

def find_command(name)
  name = name.to_s

  @path_dirs.each do |dir|
    file = File.join(dir,name)

    return file if File.file?(file) && File.executable?(file)
  end

  return nil
end