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 8 Created July 12, 2017, 3:37 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
« no previous file with comments | « modules/nodejs/manifests/init.pp ('k') | modules/nodejs/templates/nodesource.gpg.key.erb » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: modules/nodejs/manifests/package.pp
===================================================================
new file mode 100644
--- /dev/null
+++ b/modules/nodejs/manifests/package.pp
@@ -0,0 +1,51 @@
+# == Type: nodejs::package
+#
+# Manage nodejs packages.
+#
+# === Parameters:
+#
+# [*ensure*]
+# Translated directly into the state of installed/uninstalled
+# package.
+#
+define nodejs::package (
+ $ensure = 'present',
+) {
+
+ $check_command = [
+ "npm", "list",
+ "--global",
+ "--parseable",
+ $name,
+ ]
+
+ if ensure_state($ensure) {
+ $command = [
+ "npm",
+ "install", "--global",
+ $title,
+ ]
+
+ $unless = shellquote($check_command)
+ $onlyif = undef
+ }
+ else {
+ $command = [
+ "npm",
+ "uninstall", "--global",
+ $title,
+ ]
+
+ $unless = undef
+ $onlyif = shellquote($check_command)
+ }
+
+ exec {"nodejs_package_$title":
+ path => ["/usr/bin", "/bin"],
+ command => shellquote($command),
+ require => Package['nodejs'],
+ onlyif => $onlyif,
+ unless => $unless,
+ }
+}
+
« no previous file with comments | « modules/nodejs/manifests/init.pp ('k') | modules/nodejs/templates/nodesource.gpg.key.erb » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld