Sha256: 2c41c358426b0178a531107d26208f0cd2c3710be7b4064bfb3d75817350b80a

Contents?: true

Size: 946 Bytes

Versions: 1

Compression:

Stored size: 946 Bytes

Contents

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

1 entries across 1 versions & 1 rubygems

Version Path
shuttle-deploy-0.2.0.beta1 lib/shuttle/deployment/nodejs.rb