Skip to content

Instantly share code, notes, and snippets.

@dariocravero
Created June 30, 2014 12:54
Show Gist options
  • Save dariocravero/662b23871811b64b5d17 to your computer and use it in GitHub Desktop.
Save dariocravero/662b23871811b64b5d17 to your computer and use it in GitHub Desktop.
# # Modules: npm
# Adds settings and tasks for managing Ruby npm.
#
# require 'mina/npm'
# ## Settings
# Any and all of these settings can be overriden in your `deploy.rb`.
# ### npm_bin
# Sets the npm path.
set_default :npm_bin, 'npm'
# ### npm_path
# Sets the path to where the packages are expected to be.
#
# This path will be symlinked to `./shared/npm` so that the packages cache will
# be shared between all releases.
set_default :npm_path, './vendor/npm'
# ### npm_options
# Sets the options for installing packages via npm.
set_default :npm_options, lambda { %{--production --prefix "#{npm_path}"} }
# ## Deploy tasks
# These tasks are meant to be invoked inside deploy scripts, not invoked on
# their own.
namespace :npm do
# ### npm:install
# Installs packages.
desc "Install package dependencies using npm."
task :install do
queue %{
echo "-----> Installing package dependencies using npm"
#{echo_cmd %[mkdir -p "#{deploy_to}/#{shared_path}/npm"]}
#{echo_cmd %[mkdir -p "#{File.dirname npm_path}"]}
#{echo_cmd %[ln -s "#{deploy_to}/#{shared_path}/npm" "#{npm_path}"]}
#{echo_cmd %[#{npm_bin} install #{npm_options}]}
}
end
# ### npm:update
# Updates packages.
desc "Update package dependencies using npm."
task :update do
queue %{
echo "-----> Updating package dependencies using npm"
#{echo_cmd %[#{npm_bin} update]}
}
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment