Upgrade nodejs to the latest version from the repo
This is possible in newer versions of the nodejs cookbook, by setting the `node["nodejs"]["package_action"]["nodejs"]` attribute to `:upgrade`
This commit is contained in:
@@ -20,19 +20,23 @@
|
||||
#
|
||||
|
||||
resource_name :npm_package
|
||||
provides :npm_package
|
||||
|
||||
# backwards compatibility for the old resource name
|
||||
provides :nodejs_npm
|
||||
|
||||
property :package, name_property: true
|
||||
property :package, String, name_property: true
|
||||
property :version, String
|
||||
property :path, String
|
||||
property :url, String
|
||||
property :json, [String, true]
|
||||
property :json, [String, true, false]
|
||||
property :npm_token, String
|
||||
property :options, Array, default: []
|
||||
property :user, String
|
||||
property :group, String
|
||||
property :live_stream, [false, true], default: false
|
||||
property :node_env, String
|
||||
property :auto_update, [true, false], default: true
|
||||
|
||||
def initialize(*args)
|
||||
super
|
||||
@@ -46,7 +50,8 @@ action :install do
|
||||
user new_resource.user
|
||||
group new_resource.group
|
||||
environment npm_env_vars
|
||||
not_if { package_installed? }
|
||||
live_stream new_resource.live_stream
|
||||
not_if { package_installed? && no_auto_update? }
|
||||
end
|
||||
end
|
||||
|
||||
@@ -57,6 +62,7 @@ action :uninstall do
|
||||
user new_resource.user
|
||||
group new_resource.group
|
||||
environment npm_env_vars
|
||||
live_stream new_resource.live_stream
|
||||
only_if { package_installed? }
|
||||
end
|
||||
end
|
||||
@@ -69,6 +75,7 @@ action_class do
|
||||
env_vars['HOME'] = ::Dir.home(new_resource.user) if new_resource.user
|
||||
env_vars['USER'] = new_resource.user if new_resource.user
|
||||
env_vars['NPM_TOKEN'] = new_resource.npm_token if new_resource.npm_token
|
||||
env_vars['NODE_ENV'] = new_resource.node_env if new_resource.node_env
|
||||
|
||||
env_vars
|
||||
end
|
||||
@@ -77,6 +84,10 @@ action_class do
|
||||
new_resource.package && npm_package_installed?(new_resource.package, new_resource.version, new_resource.path, new_resource.npm_token)
|
||||
end
|
||||
|
||||
def no_auto_update?
|
||||
new_resource.package && !new_resource.auto_update
|
||||
end
|
||||
|
||||
def npm_options
|
||||
options = ''
|
||||
options << ' -global' unless new_resource.path
|
||||
|
||||
Reference in New Issue
Block a user