Skip to content

Commit 92c2569

Browse files
committed
Add src_url and npm_src_url attributes.
Useful in situations where there are network issues, hosting problems, and close local mirrors are present.
1 parent 2710c02 commit 92c2569

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

attributes/default.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,11 @@
2222
default['nodejs']['checksum'] = '94bbdb2d62645fd2ad5b96e41cfec68abf004fd03fabaaf7d71c48b39013cbd1'
2323
default['nodejs']['dir'] = '/usr/local'
2424
default['nodejs']['npm'] = '1.1.2'
25+
26+
nodejs_tar_path = "node-v#{node['nodejs']['version']}.tar.gz"
27+
if node['nodejs']['version'].split('.')[1].to_i >= 5
28+
nodejs_tar_path = "v#{node['nodejs']['version']}/#{nodejs_tar_path}"
29+
end
30+
31+
default['nodejs']['src_url'] = "http://nodejs.org/dist/#{nodejs_tar_path}"
32+
default['nodejs']['npm_src_url'] = "http://registry.npmjs.org/npm/-/npm-#{node['nodejs']['npm']}.tgz"

recipes/install_from_source.rb

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,9 @@
2828
end
2929

3030
nodejs_tar = "node-v#{node['nodejs']['version']}.tar.gz"
31-
nodejs_tar_path = nodejs_tar
32-
33-
if node['nodejs']['version'].split('.')[1].to_i >= 5
34-
nodejs_tar_path = "v#{node['nodejs']['version']}/#{nodejs_tar_path}"
35-
end
3631

3732
remote_file "/usr/local/src/#{nodejs_tar}" do
38-
source "http://nodejs.org/dist/#{nodejs_tar_path}"
33+
source node['nodejs']['src_url']
3934
checksum node['nodejs']['checksum']
4035
mode 0644
4136
end

recipes/npm.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
code <<-EOH
2929
mkdir -p npm-v#{node['nodejs']['npm']} && \
3030
cd npm-v#{node['nodejs']['npm']}
31-
curl -L http://registry.npmjs.org/npm/-/npm-#{node['nodejs']['npm']}.tgz | tar xzf - --strip-components=1 && \
31+
curl -L #{node['nodejs']['npm_src_url']} | tar xzf - --strip-components=1 && \
3232
make uninstall dev
3333
EOH
3434
not_if "#{node['nodejs']['dir']}/bin/npm -v 2>&1 | grep '#{node['nodejs']['npm']}'"

0 commit comments

Comments
 (0)