Skip to content

Commit

Permalink
Try to fix NPM permissions, to test!
Browse files Browse the repository at this point in the history
  • Loading branch information
Roderik van der Veer committed May 26, 2014
1 parent f6d442a commit 9aee82b
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions providers/package.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
action :install do
execute "install NPM package #{new_resource.name}" do
command "npm -g install #{new_resource.name}"
not_if "npm -g ls | grep '#{new_resource.name}'"
user node['current_user']
command "sudo -u #{node['current_user']} npm -g install #{new_resource.name}"
not_if "sudo -u #{node['current_user']} npm -g ls | grep '#{new_resource.name}'"
end
new_resource.updated_by_last_action(true)
end
Expand All @@ -12,26 +13,29 @@
pkg_id += "@#{new_resource.version}" if new_resource.version
execute "install NPM package #{new_resource.name} into #{path}" do
cwd path
command "npm install #{pkg_id}"
user node['current_user']
command "sudo -u #{node['current_user']} npm install #{pkg_id}"
not_if "cd #{path} && npm ls | grep '#{pkg_id}'"
end
new_resource.updated_by_last_action(true)
end

action :install_from_json do
path = new_resource.path
cmd = "npm install"
cmd = "sudo -u #{node['current_user']} npm install"
execute "install NPM packages from package.json at #{path}" do
cwd path
user node['current_user']
command cmd
end
new_resource.updated_by_last_action(true)
end

action :uninstall do
execute "uninstall NPM package #{new_resource.name}" do
command "npm -g uninstall #{new_resource.name}"
command "sudo -u #{node['current_user']} npm -g uninstall #{new_resource.name}"
only_if "npm -g ls | grep '#{new_resource.name}'"
user node['current_user']
end
new_resource.updated_by_last_action(true)
end
Expand All @@ -42,7 +46,8 @@
pkg_id += "@#{new_resource.version}" if new_resource.version
execute "uninstall NPM package #{new_resource.name} from #{path}" do
cwd path
command "npm uninstall #{pkg_id}"
user node['current_user']
command "sudo -u #{node['current_user']} npm uninstall #{pkg_id}"
only_if "cd #{path} && npm | grep '#{pkg_id}'"
end
new_resource.updated_by_last_action(true)
Expand Down

0 comments on commit 9aee82b

Please sign in to comment.