Skip to content

Commit

Permalink
Fix default install as non-root user, voxpupuli#305
Browse files Browse the repository at this point in the history
  • Loading branch information
fnoop committed May 2, 2018
1 parent 2880fc4 commit 17edde3
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions manifests/npm.pp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
String $package = $title,
$source = 'registry',
Array $uninstall_options = [],
$home_dir = '/root',
String $home_dir = "",
$user = undef,
Boolean $use_package_json = false,
) {
Expand Down Expand Up @@ -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 {
Expand All @@ -89,7 +95,7 @@
unless => $install_check,
user => $user,
cwd => $target,
environment => "HOME=${home_dir}",
environment => $_homedir,
require => Class['nodejs'],
}
}
Expand Down

0 comments on commit 17edde3

Please sign in to comment.