capistrano-nvm 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 02a785e076b46e058dae28e65c8a47acb52b5523
4
+ data.tar.gz: b4344bd9759ff77368f7a7fcfc0f55bd503e2579
5
+ SHA512:
6
+ metadata.gz: 0b8602193ca3e4c0711be0b72baf308a76b37773e0dffd578d25f8fc61834daed1e430243a9a26b61aea9aa8ff22f42d263810c7b479f0f6f8a6f6e14ba7357c
7
+ data.tar.gz: ce920c0b54e646a1c20a56218fcb413c787a5643c2b35823ee9666946cfdc18903624087bea10ba68b5e4ac0b486fd8760dd16f7ef2a69d592a433dbaac54349
data/README.md CHANGED
@@ -1,14 +1,15 @@
1
1
  # Capistrano::nvm
2
2
 
3
- This gem provides idiomatic [nvm](https://github.com/creationix/nvm) support for Capistrano 3.x (and 3.x
4
- *only*).
3
+ [nvm](https://github.com/creationix/nvm) support for Capistrano 3.x
5
4
 
6
5
  ## Installation
7
6
 
8
7
  Add this line to your application's Gemfile:
9
8
 
10
- gem 'capistrano', '~> 3.0'
11
- gem 'capistrano-nvm', github: "koenpunt/capistrano-nvm"
9
+ ```ruby
10
+ gem 'capistrano', '~> 3.0'
11
+ gem 'capistrano-nvm'
12
+ ```
12
13
 
13
14
  And then execute:
14
15
 
@@ -17,12 +18,19 @@ And then execute:
17
18
 
18
19
  ## Usage
19
20
 
20
- # Capfile
21
+ Require in `Capfile` to use the default task:
21
22
 
22
- require 'capistrano/nvm'
23
+ ```ruby
24
+ require 'capistrano/nvm'
25
+ ```
23
26
 
24
- set :nvm_type, :user # or :system, depends on your nvm setup
25
- set :nvm_node, 'v0.10.21'
27
+ Configurable options:
28
+
29
+ ```ruby
30
+ set :nvm_type, :user # or :system, depends on your nvm setup
31
+ set :nvm_node, 'v0.10.21'
32
+ set :nvm_map_bins, %w{node npm}
33
+ ```
26
34
 
27
35
  If your nvm is located in some custom path, you can use `nvm_custom_path` to set it.
28
36
 
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = 'capistrano-nvm'
7
- spec.version = '0.0.1'
7
+ spec.version = '0.0.2'
8
8
  spec.authors = ['Koen Punt']
9
9
  spec.email = ['me@koen.pt']
10
10
  spec.description = %q{nvm support for Capistrano 3.x}
@@ -17,7 +17,7 @@ Gem::Specification.new do |spec|
17
17
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
18
  spec.require_paths = ['lib']
19
19
 
20
- spec.add_dependency 'capistrano', '>= 3.0.0.pre'
20
+ spec.add_dependency 'capistrano', '~> 3.0.0'
21
21
 
22
22
  spec.add_development_dependency 'bundler', '~> 1.3'
23
23
  spec.add_development_dependency 'rake'
@@ -1,9 +1,5 @@
1
- namespace :deploy do
2
- before :starting, :'nvm:check'
3
- end
4
-
5
1
  namespace :nvm do
6
- task :check do
2
+ task validate: :'nvm:wrapper' do
7
3
  on roles(:all) do
8
4
  nvm_node = fetch(:nvm_node)
9
5
  if nvm_node.nil?
@@ -11,34 +7,47 @@ namespace :nvm do
11
7
  exit 1
12
8
  end
13
9
 
14
- unless test "[ -d #{fetch(:nvm_node_dir)} ]"
15
- error "nvm: #{nvm_node} is not installed or not found in #{fetch(:nvm_node_dir)}"
10
+ unless test "[ -d #{fetch(:nvm_node_path)} ]"
11
+ error "nvm: #{nvm_node} is not installed or not found in #{fetch(:nvm_node_path)}"
16
12
  exit 1
17
13
  end
14
+ end
15
+ end
16
+
17
+ task :map_bins do
18
+ nvm_prefix = fetch(:nvm_prefix, -> { "NODE_VERSION=#{fetch(:nvm_node)} #{fetch(:tmp_dir)}/#{fetch(:application)}/nvm-exec.sh" } )
19
+ fetch(:nvm_map_bins).each do |command|
20
+ SSHKit.config.command_map.prefix[command.to_sym].unshift(nvm_prefix)
21
+ end
22
+ end
18
23
 
19
- default_env = fetch(:default_env)
20
- default_env[:path] = if default_env[:path].nil?
21
- "#{fetch(:nvm_bin_path)}:$PATH"
22
- else
23
- "#{fetch(:nvm_bin_path)}:#{default_env[:path]}"
24
- end
24
+ task :wrapper do
25
+ on roles(:all) do
26
+ execute :mkdir, "-p", "#{fetch(:tmp_dir)}/#{fetch(:application)}/"
27
+ upload! StringIO.new("#!/bin/bash -e\nsource \"#{fetch(:nvm_path)}/nvm.sh\"\nnvm use $NODE_VERSION\nexec \"$@\""), "#{fetch(:tmp_dir)}/#{fetch(:application)}/nvm-exec.sh"
28
+ execute :chmod, "+x", "#{fetch(:tmp_dir)}/#{fetch(:application)}/nvm-exec.sh"
25
29
  end
26
30
  end
27
31
  end
28
32
 
33
+ Capistrano::DSL.stages.each do |stage|
34
+ after stage, 'nvm:validate'
35
+ after stage, 'nvm:map_bins'
36
+ end
37
+
29
38
  namespace :load do
30
39
  task :defaults do
31
40
 
32
- set :nvm_dir, -> {
33
- nvm_dir = fetch(:nvm_custom_dir)
34
- nvm_dir ||= if fetch(:nvm_type, :user) == :system
41
+ set :nvm_path, -> {
42
+ nvm_path = fetch(:nvm_custom_path)
43
+ nvm_path ||= if fetch(:nvm_type, :user) == :system
35
44
  "/usr/local/nvm"
36
45
  else
37
46
  "~/.nvm"
38
47
  end
39
48
  }
40
49
 
41
- set :nvm_node_dir, -> { "#{fetch(:nvm_dir)}/#{fetch(:nvm_node)}" }
42
- set :nvm_bin_path, -> { "#{fetch(:nvm_node_dir)}/bin" }
50
+ set :nvm_node_path, -> { "#{fetch(:nvm_path)}/#{fetch(:nvm_node)}" }
51
+ set :nvm_map_bins, %w{node npm}
43
52
  end
44
53
  end
metadata CHANGED
@@ -1,36 +1,32 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano-nvm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
5
- prerelease:
4
+ version: 0.0.2
6
5
  platform: ruby
7
6
  authors:
8
7
  - Koen Punt
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-11-05 00:00:00.000000000 Z
11
+ date: 2013-12-07 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: capistrano
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - ~>
20
18
  - !ruby/object:Gem::Version
21
- version: 3.0.0.pre
19
+ version: 3.0.0
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - ~>
28
25
  - !ruby/object:Gem::Version
29
- version: 3.0.0.pre
26
+ version: 3.0.0
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: bundler
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
31
  - - ~>
36
32
  - !ruby/object:Gem::Version
@@ -38,7 +34,6 @@ dependencies:
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
38
  - - ~>
44
39
  - !ruby/object:Gem::Version
@@ -46,17 +41,15 @@ dependencies:
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: rake
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - '>='
52
46
  - !ruby/object:Gem::Version
53
47
  version: '0'
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
52
+ - - '>='
60
53
  - !ruby/object:Gem::Version
61
54
  version: '0'
62
55
  description: nvm support for Capistrano 3.x
@@ -76,32 +69,25 @@ files:
76
69
  homepage: https://github.com/koenpunt/capistrano-nvm
77
70
  licenses:
78
71
  - MIT
72
+ metadata: {}
79
73
  post_install_message:
80
74
  rdoc_options: []
81
75
  require_paths:
82
76
  - lib
83
77
  required_ruby_version: !ruby/object:Gem::Requirement
84
- none: false
85
78
  requirements:
86
- - - ! '>='
79
+ - - '>='
87
80
  - !ruby/object:Gem::Version
88
81
  version: '0'
89
- segments:
90
- - 0
91
- hash: 2827476677612085551
92
82
  required_rubygems_version: !ruby/object:Gem::Requirement
93
- none: false
94
83
  requirements:
95
- - - ! '>='
84
+ - - '>='
96
85
  - !ruby/object:Gem::Version
97
86
  version: '0'
98
- segments:
99
- - 0
100
- hash: 2827476677612085551
101
87
  requirements: []
102
88
  rubyforge_project:
103
- rubygems_version: 1.8.23
89
+ rubygems_version: 2.0.14
104
90
  signing_key:
105
- specification_version: 3
91
+ specification_version: 4
106
92
  summary: nvm support for Capistrano 3.x
107
93
  test_files: []