X-Git-Url: https://git.openstreetmap.org/chef.git/blobdiff_plain/f30f230da23603e3c7598205219ce01e9820c470..176d46fe9b5deb4080f433b1ca7f7786492fda9a:/cookbooks/nodejs/providers/package.rb diff --git a/cookbooks/nodejs/providers/package.rb b/cookbooks/nodejs/providers/package.rb index 4c852732f..0ecd08eba 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"] || {} @@ -41,25 +43,29 @@ action :install do end if !@packages.include?(new_resource.package_name) - shell_out!("npm install --global #{package_name}") - new_resource.updated_by_last_action(true) + converge_by "install #{package_name}" do + shell_out!("npm install --global #{package_name}") + 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) + converge_by "update #{package_name}" do + shell_out!("npm install --global #{package_name}") + end end end action :upgrade do if @packages.include?(new_resource.package_name) - shell_out!("npm update --global #{new_resource.package_name}") - new_resource.updated_by_last_action(true) + converge_by "update #{new_resource.package_name}" do + shell_out!("npm update --global #{new_resource.package_name}") + end end end action :remove do if @packages.include?(new_resource.package_name) - shell_out!("npm remove --global #{new_resource.package_name}") - new_resource.updated_by_last_action(true) + converge_by "remove #{new_resource.package_name}" do + shell_out!("npm remove --global #{new_resource.package_name}") + end end end