Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: modules/nodejs/manifests/package.pp

Issue 29483578: #2007 - Introduce nodejs module (Closed)
Patch Set: For comment 6, ensure_resources prefered in order to avoid using the present parameter for a simpleā€¦ Created July 11, 2017, 10:04 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: modules/nodejs/manifests/package.pp
===================================================================
new file mode 100644
--- /dev/null
+++ b/modules/nodejs/manifests/package.pp
@@ -0,0 +1,57 @@
+# == 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 = [],
mathias 2017/07/11 22:28:03 Are you sure we still need that $options parameter
+) {
+
+ $check_command = [
+ "npm", "list",
+ "--global",
+ "--parseable",
+ $name,
+ ]
+
+ if ensure_state($ensure) {
+ $command = [
+ "npm",
+ "install", "--global",
+ $options,
+ $title,
+ ]
+
+ $unless = shellquote($check_command)
+ $onlyif = undef
+ }
+ else {
+ $command = [
+ "npm",
+ "uninstall", "--global",
+ $options,
+ $title,
+ ]
+
+ $unless = undef
+ $onlyif = shellquote($check_command)
+ }
+
+ exec {"state_$title":
mathias 2017/07/11 22:28:03 Not a good title, no association with the type def
+ path => ["/usr/bin"],
mathias 2017/07/11 22:28:03 Not sure but this path seems too short. I am sure
+ command => shellquote($command),
+ require => Package['nodejs'],
+ onlyif => $onlyif,
+ unless => $unless,
+ }
+}
+

Powered by Google App Engine
This is Rietveld