Class: GulpRunner::CommandUtils

Inherits:
Object
  • Object
show all
Defined in:
lib/gulp-runner/command_utils.rb

Class Method Summary collapse

Class Method Details

.find_command(cmd, paths = []) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/gulp-runner/command_utils.rb', line 12

def self.find_command(cmd, paths = [])
  exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']
  paths += ENV['PATH'].split(File::PATH_SEPARATOR)
  paths.each do |path|
    exts.each do |ext|
      exe = File.join(path, "#{cmd}#{ext}")
      return exe if (File.executable?(exe) && File.file?(exe))
    end
  end
  nil
end

.get_command(command_name) ⇒ Object

Raises:

  • (Exception)


3
4
5
6
7
8
9
10
# File 'lib/gulp-runner/command_utils.rb', line 3

def self.get_command(command_name)
  entries = Dir.entries(GulpRunner.root_path)
  npm_path = File.join(GulpRunner.root_path, 'node_modules', '.bin')
  command = CommandUtils.find_command(command_name, [npm_path])
  
  return command if !command.nil?
  raise Exception
end