class Shuttle::Nodejs

Public Instance Methods

deploy() click to toggle source
# File lib/shuttle/deployment/nodejs.rb, line 13
def deploy
  setup
  update_code
  checkout_code
  install_dependencies
  link_release
  cleanup_releases
end
setup() click to toggle source
Calls superclass method Shuttle::Strategy#setup
# File lib/shuttle/deployment/nodejs.rb, line 3
def setup
  if node_installed?
    log "Using Node.js v#{node_version}, Npm v#{npm_version}"
  else
    error "Node.js is not installed."
  end

  super
end

Private Instance Methods

install_dependencies() click to toggle source
# File lib/shuttle/deployment/nodejs.rb, line 36
def install_dependencies
  if ssh.file_exists?("#{release_path}/package.json")
    log "Installing application dependencies"

    result = ssh.run("cd #{release_path} && npm install")

    if result.failure?
      error "Unable to install dependencies: #{result.output}"
    end
  end
end
node_installed?() click to toggle source
# File lib/shuttle/deployment/nodejs.rb, line 24
def node_installed?
  ssh.run("which node").success?
end
node_version() click to toggle source
# File lib/shuttle/deployment/nodejs.rb, line 28
def node_version
  ssh.run("node -v").output.strip.gsub('v', '')
end
npm_version() click to toggle source
# File lib/shuttle/deployment/nodejs.rb, line 32
def npm_version
  ssh.run("npm -v").output.strip
end