]> git.openstreetmap.org Git - chef.git/blobdiff - cookbooks/nodejs/providers/package.rb
Fix paths in letsencrypt renewal scripts
[chef.git] / cookbooks / nodejs / providers / package.rb
index 5e3ca068468a9377f44ca1a0d464b8354cb45edd..9d83f40ffe755cd2b42ce1cf2a34fca1936d08dd 100644 (file)
@@ -22,33 +22,33 @@ require "json"
 
 include Chef::Mixin::ShellOut
 
+use_inline_resources
+
 def load_current_resource
   @packages = JSON.parse(shell_out("npm list --global --json").stdout)["dependencies"] || {}
 
   @current_resource = Chef::Resource::NodejsPackage.new(new_resource.name)
   @current_resource.package_name(new_resource.package_name)
-  if package = @packages[@current_resource.package_name]
+  if (package = @packages[@current_resource.package_name])
     @current_resource.version(package["version"])
   end
   @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