Skip to content
Snippets Groups Projects
Commit c2a713cc authored by Cédric Moreau's avatar Cédric Moreau
Browse files

[enh] Allow to parameterize the NPM and CWD vars for plugin installation/removal

parent 1f3bbe4c
No related branches found
No related tags found
No related merge requests found
......@@ -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)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment