| 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 # [*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 = [], | |
|
mathias
2017/07/11 22:28:03
Are you sure we still need that $options parameter
| |
| 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 $unless = shellquote($check_command) | 29 $unless = shellquote($check_command) |
| 35 $onlyif = undef | 30 $onlyif = undef |
| 36 } | 31 } |
| 37 else { | 32 else { |
| 38 $command = [ | 33 $command = [ |
| 39 "npm", | 34 "npm", |
| 40 "uninstall", "--global", | 35 "uninstall", "--global", |
| 41 $options, | |
| 42 $title, | 36 $title, |
| 43 ] | 37 ] |
| 44 | 38 |
| 45 $unless = undef | 39 $unless = undef |
| 46 $onlyif = shellquote($check_command) | 40 $onlyif = shellquote($check_command) |
| 47 } | 41 } |
| 48 | 42 |
| 49 exec {"state_$title": | 43 exec {"nodejs_package_$title": |
|
mathias
2017/07/11 22:28:03
Not a good title, no association with the type def
| |
| 50 path => ["/usr/bin"], | 44 path => ["/usr/bin", "/bin"], |
|
mathias
2017/07/11 22:28:03
Not sure but this path seems too short. I am sure
| |
| 51 command => shellquote($command), | 45 command => shellquote($command), |
| 52 require => Package['nodejs'], | 46 require => Package['nodejs'], |
| 53 onlyif => $onlyif, | 47 onlyif => $onlyif, |
| 54 unless => $unless, | 48 unless => $unless, |
| 55 } | 49 } |
| 56 } | 50 } |
| 57 | 51 |
| LEFT | RIGHT |