Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for npm proxy configuration. #12

Merged
merged 1 commit into from
Jun 8, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
# Usage:
#
class nodejs(
$dev_package = false
$dev_package = false,
$proxy = ''
) inherits nodejs::params {

case $::operatingsystem {
Expand Down Expand Up @@ -67,6 +68,14 @@
require => Anchor['nodejs::repo']
}

if $proxy {
exec { 'npm_proxy':
command => "npm config set proxy ${proxy}",
path => $::path,
require => Package['npm'],
}
}

if $dev_package and $nodejs::params::dev_pkg {
package { 'nodejs-dev':
name => $nodejs::params::dev_pkg,
Expand Down
3 changes: 3 additions & 0 deletions manifests/npm.pp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@
path => $::path,
require => Class['nodejs'],
}

# Conditionally require npm_proxy only if resource exists.
Exec<| title=='npm_proxy' |> -> Exec["npm_install_${name}"]
} else {
exec { "npm_remove_${name}":
command => "npm remove ${npm_pkg}",
Expand Down
29 changes: 29 additions & 0 deletions spec/classes/nodejs_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,18 @@
}
end

let :params do
{ :dev_package => true, }
end

it { should contain_class('apt') }
it { should contain_apt__ppa('ppa:chris-lea/node.js') }
it { should contain_package('nodejs') }
it { should contain_package('nodejs').with({
'name' => 'nodejs',
'require' => 'Anchor[nodejs::repo]',
}) }
it { should contain_package('nodejs-dev') }
it { should contain_package('npm').with({
'name' => 'npm',
'require' => 'Anchor[nodejs::repo]',
Expand Down Expand Up @@ -76,5 +81,29 @@
it { should_not contain_package('nodejs-dev') }
end
end

describe 'when deploying with proxy' do
let :facts do
{
:operatingsystem => 'Ubuntu',
:lsbdistcodename => 'edgy',
}
end

let :params do
{ :proxy => 'http://proxy.puppetlabs.lan:80/' }
end

it { should contain_package('npm').with({
'name' => 'npm',
'require' => 'Anchor[nodejs::repo]',
}) }
it { should contain_exec('npm_proxy').with({
'command' => 'npm config set proxy http://proxy.puppetlabs.lan:80/',
'require' => 'Package[npm]',
}) }
it { should_not contain_package('nodejs-stable-release') }
end

end