set :npm_path, -> { release_path } namespace :npm do task :prepare do npm_role = fetch(:npm_role) on roles(npm_role) do npm_target_path = fetch(:npm_target_path) npm_path = fetch(:npm_path) execute "mkdir -p #{npm_target_path}" execute "cp #{npm_path}/package.json #{npm_target_path}" end end task :link do npm_role = fetch(:npm_role) on roles(npm_role) do npm_target_path = fetch(:npm_target_path) npm_path = fetch(:npm_path) execute "ln -s #{npm_target_path}/node_modules #{npm_path}/" end end end before 'npm:install', 'npm:prepare' after 'npm:install', 'npm:link'