-
-
Notifications
You must be signed in to change notification settings - Fork 246
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
Fix default install as non-root user, #305 #363
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ | |
String $package = $title, | ||
$source = 'registry', | ||
Array $uninstall_options = [], | ||
$home_dir = '/root', | ||
$home_dir = undef, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This changes the default behavior of the module and would likely need a major version bump. |
||
$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 | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i think a selector is easier to read? $_homedir = $home_dir? {
undef => undef,
default => "HOME=${home_dir}",
} |
||
|
||
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'], | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of removing the test, why not modify it ? |
||
end | ||
|
||
# npm install <package> <install_options> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
while we're at it, we could just as well give home_dir an
Optional[Stdlib::AbsPath]
type.