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 define nodejs::package ( |
| 12 $ensure = 'present', |
| 13 ) { |
| 14 |
| 15 $check_command = [ |
| 16 "npm", "list", |
| 17 "--global", |
| 18 "--parseable", |
| 19 $name, |
| 20 ] |
| 21 |
| 22 if ensure_state($ensure) { |
| 23 $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), |
| 46 require => Package['nodejs'], |
| 47 onlyif => $onlyif, |
| 48 unless => $unless, |
| 49 } |
| 50 } |
| 51 |
OLD | NEW |