Skip to content

Commit ed516f6

Browse files
committed
On Unix, add a sensible exec PATH
since i don't know much about Windows, I'm leaving that as is for now. But in terms of escaping / testing, and consolidating! our testing, it would make sense to extend it to Windows as well.
1 parent 532eead commit ed516f6

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

manifests/npm.pp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,21 @@
4545
$list_command = "${npm_path} ls --long --parseable"
4646
$install_check = "${list_command} | ${grep_command} \"${target}${dirsep}node_modules${dirsep}${install_check_package_string}\""
4747

48+
# set a sensible path on Unix
49+
$exec_path = $facts['os']['family'] ? {
50+
'Windows' => undef,
51+
'Darwin' => ['/bin', '/usr/bin', '/opt/local/bin', '/usr/local/bin'],
52+
default => ['/bin', '/usr/bin', '/usr/local/bin'],
53+
}
54+
4855
if $ensure == 'absent' {
4956
$npm_command = 'rm'
5057
$options = $uninstall_options_string
5158

5259
if $use_package_json {
5360
exec { "npm_${npm_command}_${name}":
5461
command => "${npm_path} ${npm_command} * ${options}",
62+
path => $exec_path,
5563
onlyif => $list_command,
5664
user => $user,
5765
cwd => "${target}${dirsep}node_modules",
@@ -60,6 +68,7 @@
6068
} else {
6169
exec { "npm_${npm_command}_${name}":
6270
command => "${npm_path} ${npm_command} ${package_string} ${options}",
71+
path => $exec_path,
6372
onlyif => $install_check,
6473
user => $user,
6574
cwd => $target,
@@ -76,6 +85,7 @@
7685
if $use_package_json {
7786
exec { "npm_${npm_command}_${name}":
7887
command => "${npm_path} ${npm_command} ${options}",
88+
path => $exec_path,
7989
unless => $list_command,
8090
user => $user,
8191
cwd => $target,
@@ -85,6 +95,7 @@
8595
} else {
8696
exec { "npm_${npm_command}_${name}":
8797
command => "${npm_path} ${npm_command} ${package_string} ${options}",
98+
path => $exec_path,
8899
unless => $install_check,
89100
user => $user,
90101
cwd => $target,

manifests/npm/global_config_entry.pp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,16 @@
6161
default => 'shell',
6262
}
6363

64+
# set a sensible path on Unix
65+
$exec_path = $facts['os']['family'] ? {
66+
'Windows' => undef,
67+
'Darwin' => ['/bin', '/usr/bin', '/opt/local/bin', '/usr/local/bin'],
68+
default => ['/bin', '/usr/bin', '/usr/local/bin'],
69+
}
70+
6471
exec { "npm_config ${ensure} ${title}":
6572
command => "${npm_path} ${command}",
73+
path => $exec_path,
6674
provider => $provider,
6775
onlyif => $onlyif_command,
6876
require => $exec_require,

0 commit comments

Comments
 (0)