Class: Vx::Builder::ScriptBuilderV2::Nodejs

Inherits:
Base
  • Object
show all
Defined in:
lib/vx/builder/script_builder_v2/nodejs.rb

Constant Summary collapse

DEFAULT_NODE =
'0.10'
NPM_PACKAGES =
'node_modules'
BOWER_COMPONENTS =
'bower_components'

Instance Attribute Summary

Attributes inherited from Base

#app

Instance Method Summary collapse

Methods inherited from Base

#deploy?, #do_after_deploy, #do_before_deploy, #do_before_script, #do_cache_key, #do_cached_directories, #do_database, #do_deploy_script, #do_install, #do_script

Instance Method Details

#call(env) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/vx/builder/script_builder_v2/nodejs.rb', line 11

def call(env)
  if enabled?(env)

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

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

    env.stage("install").tap do |i|
      i.add_env 'PATH', "${PATH}:${PWD}/#{NPM_PACKAGES}/bin"
      i.add_task "vxvm", "nodejs #{node_version(env)}"
      i.add_task "shell", 'npm config set spin false'
      i.add_task 'shell', 'node --version'
      i.add_task 'shell', 'npm --version'

      do_install(env) do
        i.add_task 'shell', 'npm install'
      end
    end

    do_script(env) do
      env.stage("script").tap do |i|
        i.add_task 'shell', 'npm test'
      end
    end
  end

  app.call(env)
end