27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
# File 'lib/resources/npm.rb', line 27
def info
return @info if defined?(@info)
if @location
npm = "cd #{Shellwords.escape @location} && npm"
else
npm = 'npm -g'
end
cmd = inspec.command("#{npm} ls --json #{@package_name}")
@info = {
name: @package_name,
type: 'npm',
installed: cmd.exit_status == 0,
}
return @info unless @info[:installed]
pkgs = JSON.parse(cmd.stdout)
@info[:version] = pkgs['dependencies'][@package_name]['version']
@info
end
|