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: For comment 4 Created July 11, 2017, 6:14 p.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 # [*ensure*] 7 # [*ensure*]
8 # Translated directly into the state of installed/uninstalled 8 # Translated directly into the state of installed/uninstalled
9 # package. 9 # package.
10 # 10 #
11 # [*options*]
12 # A list of zero or more options to install the package.
13 #
14 define nodejs::package ( 11 define nodejs::package (
15 $ensure = 'present', 12 $ensure = 'present',
16 $options = [],
17 ) { 13 ) {
18 14
19 $check_command = [ 15 $check_command = [
20 "npm", "list", 16 "npm", "list",
21 "--global", 17 "--global",
22 "--parseable", 18 "--parseable",
23 $name, 19 $name,
24 ] 20 ]
25 21
26 if ensure_state($ensure) { 22 if ensure_state($ensure) {
27 $command = [ 23 $command = [
28 "npm", 24 "npm",
29 "install", "--global", 25 "install", "--global",
30 $options,
31 $title, 26 $title,
32 ] 27 ]
33 28
34 $onlyif = shellquote("test", "!", "`${check_command}`") 29 $unless = shellquote($check_command)
mathias 2017/07/11 18:24:42 That doesn't make any sense: The backticks are esc
30 $onlyif = undef
35 } 31 }
36 else { 32 else {
37 $command = [ 33 $command = [
38 "npm", 34 "npm",
39 "uninstall", "--global", 35 "uninstall", "--global",
40 $options,
41 $title, 36 $title,
42 ] 37 ]
43 38
44 $onlyif = shellquote("test", "`${check_command}`") 39 $unless = undef
40 $onlyif = shellquote($check_command)
45 } 41 }
46 42
47 exec {"state_$title": 43 exec {"nodejs_package_$title":
48 path => ["/usr/bin"], 44 path => ["/usr/bin", "/bin"],
49 command => shellquote($command), 45 command => shellquote($command),
50 require => Package['nodejs'], 46 require => Package['nodejs'],
51 onlyif => $onlyif, 47 onlyif => $onlyif,
48 unless => $unless,
52 } 49 }
53 } 50 }
54 51
LEFTRIGHT

Powered by Google App Engine
This is Rietveld