Permalink
Browse files

Adds 'npm' installer

  • Loading branch information...
1 parent 4115242 commit 2f6fbeee842a3dff6af0cb176d214457bf3de571 @jbottigliero jbottigliero committed Dec 18, 2012
@@ -0,0 +1,19 @@
+module Sprinkle
+ module Installers
+
+ class Npm < Installer
+ attr_accessor :package_name
+
+ def initialize(parent, package_name, &block)
+ super parent, &block
+ @package_name = package_name
+ end
+
+ protected
+ def install_commands #override
+ "npm install --global #{@package_name}"
+ end
+
+ end #of class
+ end #module
+end #module
View
@@ -232,6 +232,10 @@ def pear(thePackage, &block)
logger.debug("the pear installer is " + installer.to_s)
@installers << installer;
end
+
+ def npm(thePackage, &block)
+ @installers << Sprinkle::Installers::Npm.new(self, thePackage, &block);
+ end
def process(deployment, roles)
return if meta_package?
@@ -0,0 +1,21 @@
+module Sprinkle
+ module Verifiers
+ # = Npm package Verifier
+ #
+ # Contains a verifier to check the existence of a npm module.
+ #
+ # == Example Usage
+ #
+ # verify { has_npm 'grunt' }
+ #
+ module Npm
+ Sprinkle::Verify.register(Sprinkle::Verifiers::Npm)
+
+ # Checks to make sure the npm <tt>module</tt> exists on the remote server.
+ def has_npm(package)
+ @commands << "npm -g list | grep \"#{package}\""
+ end
+
+ end
+ end
+end
@@ -0,0 +1,16 @@
+require File.expand_path("../../spec_helper", File.dirname(__FILE__))
+
+describe Sprinkle::Installers::Npm do
+
+ before do
+ @package = mock(Sprinkle::Package, :name => 'spec')
+ @installer = Sprinkle::Installers::Npm.new(@package, 'spec')
+ end
+
+ describe 'during installation' do
+ it 'should invoke the npm executer for all specified tasks' do
+ @install_commands = @installer.send :install_commands
+ @install_commands.should == "npm install --global spec"
+ end
+ end
+end
View
@@ -62,6 +62,7 @@ Gem::Specification.new do |s|
"lib/sprinkle/installers/install_package.rb",
"lib/sprinkle/installers/installer.rb",
"lib/sprinkle/installers/mac_port.rb",
+ "lib/sprinkle/installers/npm.rb",
"lib/sprinkle/installers/openbsd_pkg.rb",
"lib/sprinkle/installers/opensolaris_pkg.rb",
"lib/sprinkle/installers/pacman.rb",
@@ -86,6 +87,7 @@ Gem::Specification.new do |s|
"lib/sprinkle/verifiers/directory.rb",
"lib/sprinkle/verifiers/executable.rb",
"lib/sprinkle/verifiers/file.rb",
+ "lib/sprinkle/verifiers/npm.rb",
"lib/sprinkle/verifiers/package.rb",
"lib/sprinkle/verifiers/pear.rb",
"lib/sprinkle/verifiers/process.rb",
@@ -114,6 +116,7 @@ Gem::Specification.new do |s|
"spec/sprinkle/installers/gem_spec.rb",
"spec/sprinkle/installers/installer_spec.rb",
"spec/sprinkle/installers/mac_port_spec.rb",
+ "spec/sprinkle/installers/npm_spec.rb",
"spec/sprinkle/installers/openbsd_pkg_spec.rb",
"spec/sprinkle/installers/opensolaris_pkg_spec.rb",
"spec/sprinkle/installers/pear_spec.rb",

0 comments on commit 2f6fbee

Please sign in to comment.