Sha256: 57c92c820b0496c5517353a3751d71b04e1b28545c5d9f735db295cafa35d1d2

Contents?: true

Size: 948 Bytes

Versions: 24

Compression:

Stored size: 948 Bytes

Contents

module Shuttle
  class Nodejs < Shuttle::Strategy
    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

    def deploy
      setup
      update_code
      checkout_code
      install_dependencies
      link_release
      cleanup_releases
    end

    private

    def node_installed?
      ssh.run("which node").success?
    end

    def node_version
      ssh.run("node -v").output.strip.gsub('v', '')
    end

    def npm_version
      ssh.run("npm -v").output.strip
    end

    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
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
shuttle-deploy-0.2.0.beta5 lib/shuttle/deployment/nodejs.rb
shuttle-deploy-0.2.0.beta4 lib/shuttle/deployment/nodejs.rb
shuttle-deploy-0.2.0.beta3 lib/shuttle/deployment/nodejs.rb
shuttle-deploy-0.2.0.beta2 lib/shuttle/deployment/nodejs.rb