Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Delta Between Two Patch Sets: modules/nodejs/manifests/package.pp

Issue 29483578: #2007 - Introduce nodejs module (Closed)
Left Patch Set: Created July 9, 2017, 1:30 a.m.
Right Patch Set: For comment 8 Created July 12, 2017, 3:37 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « modules/nodejs/manifests/init.pp ('k') | modules/nodejs/templates/nodesource.gpg.key.erb » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 # == Type: nodejs::package 1 # == Type: nodejs::package
2 # 2 #
3 # Manage nodejs packages. 3 # Manage nodejs packages.
4 # 4 #
5 # === Parameters: 5 # === Parameters:
6 # 6 #
7 # [*options*] 7 # [*ensure*]
8 # A list of zero or more options to install the package. 8 # Translated directly into the state of installed/uninstalled
9 # package.
9 # 10 #
10 define nodejs::package ( 11 define nodejs::package (
mathias 2017/07/09 07:26:50 Shouldn't there be some $ensure parameter in order
11 $options = [], 12 $ensure = 'present',
12 ) { 13 ) {
13 14
14 $install_command = [ 15 $check_command = [
15 "npm", "install", 16 "npm", "list",
16 $options, 17 "--global",
17 $title, 18 "--parseable",
19 $name,
18 ] 20 ]
19 21
20 exec {"install_$title": 22 if ensure_state($ensure) {
21 path => ["/usr/bin"], 23 $command = [
22 command => shellquote($install_command), 24 "npm",
25 "install", "--global",
26 $title,
27 ]
28
29 $unless = shellquote($check_command)
30 $onlyif = undef
31 }
32 else {
33 $command = [
34 "npm",
35 "uninstall", "--global",
36 $title,
37 ]
38
39 $unless = undef
40 $onlyif = shellquote($check_command)
41 }
42
43 exec {"nodejs_package_$title":
44 path => ["/usr/bin", "/bin"],
45 command => shellquote($command),
23 require => Package['nodejs'], 46 require => Package['nodejs'],
24 onlyif => "test ! -x /usr/bin/${title}", 47 onlyif => $onlyif,
mathias 2017/07/09 07:26:50 Please use the 'creates' parameter instead.
48 unless => $unless,
25 } 49 }
26 } 50 }
51
LEFTRIGHT

Powered by Google App Engine
This is Rietveld