X-Git-Url: https://git.openstreetmap.org./chef.git/blobdiff_plain/9bca5f05185dde08efcf2d5f1a2bf66c8cdc9f00..14634cdec2f8091b6b5a6197a6bee033ff530582:/cookbooks/nodejs/providers/package.rb?ds=inline diff --git a/cookbooks/nodejs/providers/package.rb b/cookbooks/nodejs/providers/package.rb index 3a3304063..9d83f40ff 100644 --- a/cookbooks/nodejs/providers/package.rb +++ b/cookbooks/nodejs/providers/package.rb @@ -22,6 +22,8 @@ require "json" include Chef::Mixin::ShellOut +use_inline_resources + def load_current_resource @packages = JSON.parse(shell_out("npm list --global --json").stdout)["dependencies"] || {} @@ -34,21 +36,19 @@ def load_current_resource end action :install do - if new_resource.version - package_name = "#{new_resource.package_name}@#{new_resource.version}" - else - package_name = new_resource.package_name - end + package_name = if new_resource.version + "#{new_resource.package_name}@#{new_resource.version}" + else + new_resource.package_name + end if !@packages.include?(new_resource.package_name) shell_out!("npm install --global #{package_name}") new_resource.updated_by_last_action(true) - else - if new_resource.version && - new_resource.version != @current_resource.version - shell_out!("npm install --global #{package_name}") - new_resource.updated_by_last_action(true) - end + elsif new_resource.version && + new_resource.version != @current_resource.version + shell_out!("npm install --global #{package_name}") + new_resource.updated_by_last_action(true) end end