Index: modules/nodejs/manifests/package.pp |
=================================================================== |
new file mode 100644 |
--- /dev/null |
+++ b/modules/nodejs/manifests/package.pp |
@@ -0,0 +1,47 @@ |
+# == 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 = [], |
+) { |
+ |
+ if ensure_state($ensure) { |
+ $command = [ |
+ "npm", |
+ "install", |
+ $options, |
+ $title, |
+ ] |
+ |
+ $creates = "/usr/bin/${title}" |
mathias
2017/07/10 22:33:40
Are you sure every package will create a file or e
|
+ } |
+ else { |
+ $command = [ |
+ "npm", |
+ "uninstall", |
+ $options, |
+ $title, |
+ ] |
+ |
+ $creates = undef |
+ } |
+ |
+ exec {"state_$title": |
+ path => ["/usr/bin"], |
+ command => shellquote($command), |
+ require => Package['nodejs'], |
+ creates => $creates, |
+ } |
+} |
+ |