class Isomorfeus::Speednode::NodeCommand

Public Class Methods

cached(command) click to toggle source
# File lib/isomorfeus/speednode/node_command.rb, line 15
def self.cached(command)
  @cached_command ||= which(command)
end
which(command) click to toggle source
# File lib/isomorfeus/speednode/node_command.rb, line 4
def self.which(command)
  Array(command).find do |name|
    name, args = name.split(/\s+/, 2)
    path = locate_executable(name)

    next unless path

    args ? "#{path} #{args}" : path
  end
end

Private Class Methods

locate_executable(command) click to toggle source
# File lib/isomorfeus/speednode/node_command.rb, line 21
def self.locate_executable(command)
  commands = Array(command)
  if ExecJS.windows? && File.extname(command) == ""
    ENV['PATHEXT'].split(File::PATH_SEPARATOR).each { |p|
      commands << (command + p)
    }
  end

  commands.find { |cmd|
    if File.executable? cmd
      cmd
    else
      path = ENV['PATH'].split(File::PATH_SEPARATOR).find { |p|
        full_path = File.join(p, cmd)
        File.executable?(full_path) && File.file?(full_path)
      }
      path && File.expand_path(cmd, path)
    end
  }
end