Sha256: 09dfdd8dd7b8af1e3aacfdd02e5a7166c52639cd6192fcf3cf2fe157e49f605c

Contents?: true

Size: 1.34 KB

Versions: 9

Compression:

Stored size: 1.34 KB

Contents

module Vx
  module Builder
    class ScriptBuilder

      class Nodejs < Base

        DEFAULT_NODE = '0.10'
        NPM_PACKAGES = '~/.npm-packages'

        def call(env)
          if enabled?(env)

            vxvm_install(env, 'nodejs', node_version(env))

            do_cache_key(env) do |i|
              i << "nodejs-#{node_version env}"
            end

            do_announce(env) do |i|
              i << trace_sh_command("node --version")
              i << trace_sh_command("npm --version")
            end

            do_install(env) do |i|
              i << trace_sh_command("npm install")
            end

            do_script(env) do |i|
              i << trace_sh_command("npm test")
            end

            do_before_install(env) do |i|
              i << "mkdir -p #{NPM_PACKAGES}"
              i << trace_sh_command("npm config set prefix=#{NPM_PACKAGES}")
              i << "export PATH=$PATH:#{NPM_PACKAGES}/bin"
            end

            do_cached_directories(env) do |i|
              i << NPM_PACKAGES
            end
          end

          app.call(env)
        end

        private

          def enabled?(env)
            env.source.node_js.first || env.source.language == 'node_js'
          end

          def node_version(env)
            env.source.node_js.first || DEFAULT_NODE
          end

      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
vx-builder-0.5.21 lib/vx/builder/script_builder/nodejs.rb
vx-builder-0.5.20 lib/vx/builder/script_builder/nodejs.rb
vx-builder-0.5.19 lib/vx/builder/script_builder/nodejs.rb
vx-builder-0.5.18 lib/vx/builder/script_builder/nodejs.rb
vx-builder-0.5.17 lib/vx/builder/script_builder/nodejs.rb
vx-builder-0.5.16 lib/vx/builder/script_builder/nodejs.rb
vx-builder-0.5.15 lib/vx/builder/script_builder/nodejs.rb
vx-builder-0.5.14 lib/vx/builder/script_builder/nodejs.rb
vx-builder-0.5.13 lib/vx/builder/script_builder/nodejs.rb