| Index: modules/nodejs/manifests/package.pp |
| =================================================================== |
| new file mode 100644 |
| --- /dev/null |
| +++ b/modules/nodejs/manifests/package.pp |
| @@ -0,0 +1,54 @@ |
| +# == Type: nodejs::package |
| +# |
| +# Manage nodejs packages. |
| +# |
| +# === Parameters: |
| +# |
| +# [*ensure*] |
| +# Translated directly into the state of installed/uninstalled |
| +# package. |
| +# |
| +# [*options*] |
| +# A list of zero or more options to install the package. |
| +# |
| +define nodejs::package ( |
| + $ensure = 'present', |
| + $options = [], |
| +) { |
| + |
| + $check_command = [ |
| + "npm", "list", |
| + "--global", |
| + "--parseable", |
| + $name, |
| + ] |
| + |
| + if ensure_state($ensure) { |
| + $command = [ |
| + "npm", |
| + "install", "--global", |
| + $options, |
| + $title, |
| + ] |
| + |
| + $onlyif = shellquote("test", "!", "`${check_command}`") |
|
mathias
2017/07/11 18:24:42
That doesn't make any sense: The backticks are esc
|
| + } |
| + else { |
| + $command = [ |
| + "npm", |
| + "uninstall", "--global", |
| + $options, |
| + $title, |
| + ] |
| + |
| + $onlyif = shellquote("test", "`${check_command}`") |
| + } |
| + |
| + exec {"state_$title": |
| + path => ["/usr/bin"], |
| + command => shellquote($command), |
| + require => Package['nodejs'], |
| + onlyif => $onlyif, |
| + } |
| +} |
| + |