Left: | ||
Right: |
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 # [*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 | |
LEFT | RIGHT |