From c2a713cc34c78aebbb4e31ea576fd8ec3a8962e3 Mon Sep 17 00:00:00 2001
From: cgeek <cem.moreau@gmail.com>
Date: Wed, 24 May 2017 21:32:13 +0200
Subject: [PATCH] =?UTF-8?q?[enh]=C2=A0Allow=20to=20parameterize=20the=20NP?=
 =?UTF-8?q?M=20and=20CWD=20vars=20for=20plugin=20installation/removal?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 app/modules/plugin.js | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/app/modules/plugin.js b/app/modules/plugin.js
index 5c6708376..a43c114c0 100644
--- a/app/modules/plugin.js
+++ b/app/modules/plugin.js
@@ -9,7 +9,9 @@ module.exports = {
   duniter: {
 
     methods: {
-      canWrite: getNPMAccess
+      canWrite: getNPMAccess,
+      npmInstall,
+      npmRemove
     },
 
     cli: [{
@@ -50,10 +52,10 @@ module.exports = {
   }
 }
 
-function npmInstall(what) {
+function npmInstall(what, npm, cwd) {
   return new Promise((res, rej) => {
-    const npm = getNPM()
-    const cwd = getCWD()
+    npm = npm || getNPM()
+    cwd = cwd || getCWD()
     const install = spawn(npm, ['i', '--save', what], { cwd })
 
     install.stdout.pipe(process.stdout)
@@ -77,10 +79,10 @@ function npmInstall(what) {
 }
 
 
-function npmRemove(what) {
+function npmRemove(what, npm, cwd) {
   return new Promise((res, rej) => {
-    const npm = getNPM()
-    const cwd = getCWD()
+    npm = npm || getNPM()
+    cwd = cwd || getCWD()
     const uninstall = spawn(npm, ['remove', '--save', what], { cwd })
 
     uninstall.stdout.pipe(process.stdout)
-- 
GitLab