Class: Puppet::Util::Npm

Inherits:
Object
  • Object
show all
Defined in:
lib/puppet/util/npm.rb

Class Method Summary collapse

Class Method Details

.npm_checkObject



15
16
17
# File 'lib/puppet/util/npm.rb', line 15

def self.npm_check
  !which('npm').nil? && !which('npm').empty?
end

.which(cmd) ⇒ Object



4
5
6
7
8
9
10
11
12
13
# File 'lib/puppet/util/npm.rb', line 4

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