Class: Bixby::Provision::Packager::NPM
- Inherits:
-
PackagerBase
- Object
- Base
- PackagerBase
- Bixby::Provision::Packager::NPM
- Defined in:
- lib/bixby/provision/dsl/packager/npm.rb
Constant Summary
Constants inherited from Base
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
Methods inherited from Base
#get_gid, #get_group, #get_uid, #get_user, #initialize, #tap
Methods included from Util::File
#chmod, #chown, #sha256sum, #which
Constructor Details
This class inherits a constructor from Bixby::Provision::Base
Instance Method Details
#install(*packages) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/bixby/provision/dsl/packager/npm.rb', line 8 def install(*packages) if packages.last.kind_of? Hash then opts = packages.pop else opts = {} end packages = packages.flatten.sort logger.info "npm install: " + packages.join(" ") installed = query_installed_packages(packages, opts) needed = packages.find_all{ |s| !installed.include? s } if needed.empty? then logger.info "[npm] package(s) already installed" return end global = opts[:global] if global then cmd = "npm install -g " + packages.join(" ") logged_sudo(cmd, env) else cmd = "npm install " + packages.join(" ") logged_systemu(cmd, env) end end |
#installed?(package, opts = {}) ⇒ Boolean
35 36 37 |
# File 'lib/bixby/provision/dsl/packager/npm.rb', line 35 def installed?(package, opts={}) query_installed_packages(package, opts).include? package end |