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