LEFT | RIGHT |
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) |
| 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 |
LEFT | RIGHT |