diff --git a/manifests/npm.pp b/manifests/npm.pp index 8b4924a3..d046da77 100644 --- a/manifests/npm.pp +++ b/manifests/npm.pp @@ -8,7 +8,7 @@ String $package = $title, $source = 'registry', Array $uninstall_options = [], - $home_dir = '/root', + $home_dir = undef, $user = undef, Boolean $use_package_json = false, ) { @@ -74,13 +74,19 @@ Nodejs::Npm::Global_config_entry<| title == 'https-proxy' |> -> Exec["npm_install_${name}"] Nodejs::Npm::Global_config_entry<| title == 'proxy' |> -> Exec["npm_install_${name}"] + if !empty($home_dir) { + $_homedir = "HOME=${home_dir}" + } else { + $_homedir = undef + } + if $use_package_json { exec { "npm_${npm_command}_${name}": command => "${npm_path} ${npm_command} ${options}", unless => $list_command, user => $user, cwd => $target, - environment => "HOME=${home_dir}", + environment => $_homedir, require => Class['nodejs'], } } else { @@ -89,7 +95,7 @@ unless => $install_check, user => $user, cwd => $target, - environment => "HOME=${home_dir}", + environment => $_homedir, require => Class['nodejs'], } } diff --git a/spec/defines/nodejs_npm_spec.rb b/spec/defines/nodejs_npm_spec.rb index 5a8b4559..bd370e03 100644 --- a/spec/defines/nodejs_npm_spec.rb +++ b/spec/defines/nodejs_npm_spec.rb @@ -52,10 +52,6 @@ it 'the exec directory should be /home/npm/packages' do is_expected.to contain_exec('npm_install_express').with('cwd' => '/home/npm/packages') end - - it 'the environment variable HOME should be /root' do - is_expected.to contain_exec('npm_install_express').with('environment' => 'HOME=/root') - end end # npm install