Cope with a clean NPM install that has no packages yet
authorTom Hughes <tom@compton.nu>
Tue, 4 Jun 2013 12:23:49 +0000 (13:23 +0100)
committerTom Hughes <tom@compton.nu>
Tue, 4 Jun 2013 12:25:05 +0000 (13:25 +0100)
cookbooks/nodejs/providers/package.rb

index f726df3..ec20d15 100644 (file)
@@ -23,7 +23,7 @@ require "json"
 include Chef::Mixin::ShellOut
 
 def load_current_resource
-  @packages = JSON.parse(shell_out("npm list --global --json").stdout)["dependencies"]
+  @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)