This repository has been archived by the owner on Jun 13, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enhancement: support to actually install any version npm we need
- Loading branch information
Showing
2 changed files
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
npm_bin = '/usr/bin/npm' | ||
|
||
local_latest = "#{Chef::Config[:file_cache_path]}/install-npm.sh" | ||
|
||
npm_version = node['nodejs']['npm']['version'] | ||
|
||
is_correct_version = ->(version) { | ||
`npm -v`.strip! == version | ||
} | ||
|
||
remote_file local_latest do | ||
source 'https://www.npmjs.org/install.sh' | ||
mode '0755' | ||
not_if do | ||
File.exist?(local_latest) || is_correct_version[npm_version] | ||
end | ||
end | ||
|
||
package "curl" do | ||
action :install | ||
only_if do | ||
File.exist?(local_latest) | ||
end | ||
end | ||
|
||
execute 'Install npm' do | ||
command local_latest | ||
environment({ | ||
'clean' => 'no', | ||
'npm_install' => npm_version | ||
}) | ||
not_if do | ||
is_correct_version[npm_version] | ||
end | ||
end |