Skip to content

Commit

Permalink
Merge pull request #161 from mootpt/expose_environment_var
Browse files Browse the repository at this point in the history
Allowed home environment variable to be set
  • Loading branch information
nibalizer committed Aug 18, 2015
2 parents b9d2528 + 0ad4594 commit 2581cdd
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
12 changes: 7 additions & 5 deletions manifests/npm.pp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
$package = $title,
$source = 'registry',
$uninstall_options = [],
$home_dir = '/root',
$user = undef,
) {

Expand Down Expand Up @@ -66,11 +67,12 @@
Nodejs::Npm::Global_config_entry<| title == 'proxy' |> -> Exec["npm_install_${name}"]

exec { "npm_${npm_command}_${name}":
command => "${npm_path} ${npm_command} ${package_string} ${options}",
unless => $install_check,
user => $user,
cwd => $target,
require => Class['nodejs'],
command => "${npm_path} ${npm_command} ${package_string} ${options}",
unless => $install_check,
user => $user,
cwd => $target,
environment => "HOME=${home_dir}",
require => Class['nodejs'],
}
}
}
12 changes: 9 additions & 3 deletions spec/defines/nodejs_npm_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,25 @@
it 'the command should be npm install express' do
is_expected.to contain_exec('npm_install_express').with({
'command' => '/usr/bin/npm install express ',
})
})
end

it 'the install_check should grep for /home/npm/packages/node_modules/express' do
is_expected.to contain_exec('npm_install_express').with({
'unless' => "/usr/bin/npm ls --long --parseable | grep \"/home/npm/packages/node_modules/express\"",
})
})
end

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

Expand Down

0 comments on commit 2581cdd

Please sign in to comment.