OLD | NEW |
(Empty) | |
| 1 # == Type: nodejs::package |
| 2 # |
| 3 # Manage nodejs packages. |
| 4 # |
| 5 # === Parameters: |
| 6 # |
| 7 # [*ensure*] |
| 8 # Translated directly into the state of installed/uninstalled |
| 9 # package. |
| 10 # |
| 11 # [*options*] |
| 12 # A list of zero or more options to install the package. |
| 13 # |
| 14 define nodejs::package ( |
| 15 $ensure = 'present', |
| 16 $options = [], |
| 17 ) { |
| 18 |
| 19 $check_command = [ |
| 20 "npm", "list", |
| 21 "--global", |
| 22 "--parseable", |
| 23 $name, |
| 24 ] |
| 25 |
| 26 if ensure_state($ensure) { |
| 27 $command = [ |
| 28 "npm", |
| 29 "install", "--global", |
| 30 $options, |
| 31 $title, |
| 32 ] |
| 33 |
| 34 $onlyif = shellquote("test", "!", "`${check_command}`") |
| 35 } |
| 36 else { |
| 37 $command = [ |
| 38 "npm", |
| 39 "uninstall", "--global", |
| 40 $options, |
| 41 $title, |
| 42 ] |
| 43 |
| 44 $onlyif = shellquote("test", "`${check_command}`") |
| 45 } |
| 46 |
| 47 exec {"state_$title": |
| 48 path => ["/usr/bin"], |
| 49 command => shellquote($command), |
| 50 require => Package['nodejs'], |
| 51 onlyif => $onlyif, |
| 52 } |
| 53 } |
| 54 |
OLD | NEW |