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 2 Created July 10, 2017, 8:15 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 ) {
14
15 $check_command = [
16 "npm", "list",
17 "--global",
18 "--parseable",
19 $name,
20 ]
18 21
19 if ensure_state($ensure) { 22 if ensure_state($ensure) {
20 $command = [ 23 $command = [
21 "npm", 24 "npm",
22 "install", 25 "install", "--global",
23 $options,
24 $title, 26 $title,
25 ] 27 ]
26 28
27 $creates = "/usr/bin/${title}" 29 $unless = shellquote($check_command)
mathias 2017/07/10 22:33:40 Are you sure every package will create a file or e
30 $onlyif = undef
28 } 31 }
29 else { 32 else {
30 $command = [ 33 $command = [
31 "npm", 34 "npm",
32 "uninstall", 35 "uninstall", "--global",
33 $options,
34 $title, 36 $title,
35 ] 37 ]
36 38
37 $creates = undef 39 $unless = undef
40 $onlyif = shellquote($check_command)
38 } 41 }
39 42
40 exec {"state_$title": 43 exec {"nodejs_package_$title":
41 path => ["/usr/bin"], 44 path => ["/usr/bin", "/bin"],
42 command => shellquote($command), 45 command => shellquote($command),
43 require => Package['nodejs'], 46 require => Package['nodejs'],
44 creates => $creates, 47 onlyif => $onlyif,
48 unless => $unless,
45 } 49 }
46 } 50 }
47 51
LEFTRIGHT

Powered by Google App Engine
This is Rietveld