Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add sudo support for npm installer. #216

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions lib/sprinkle/installers/npm.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,26 @@ class Npm < Installer
attr_accessor :package_name

api do
def npm(package, &block)
install Npm.new(self, package, &block)
def npm(package, options={}, &block)
install Npm.new(self, package, options, &block)
end
end

verify_api do
def has_npm(package)
@commands << "npm --global list | grep \"#{package}@\""
@commands << "npm --global list | grep -F \"#{package}@\""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think to be correct her we need to match " [package]" (space in front), based on the output - to avoid false matches, yes? I'd say fix this and we can merge.

end
end

def initialize(parent, package_name, &block) #:nodoc:
super parent, &block
def initialize(parent, package_name, options={}, &block) #:nodoc:
super parent, options, &block
@package_name = package_name
end

protected

def install_commands #:nodoc:
"npm install --global #{@package_name}"
"#{sudo_cmd}npm install --global #{@package_name}"
end

end
Expand Down