diff --git a/app/modules/plugin.js b/app/modules/plugin.js index a43c114c0fa028350cd21a2b219dec83fa945a14..4f974dc8df74ad06dde81e6434cba909cf4478e9 100644 --- a/app/modules/plugin.js +++ b/app/modules/plugin.js @@ -54,9 +54,10 @@ module.exports = { function npmInstall(what, npm, cwd) { return new Promise((res, rej) => { + const node = getNode() npm = npm || getNPM() cwd = cwd || getCWD() - const install = spawn(npm, ['i', '--save', what], { cwd }) + const install = spawn(node, [npm, 'i', '--save', what], { cwd }) install.stdout.pipe(process.stdout) install.stderr.pipe(process.stderr) @@ -81,9 +82,10 @@ function npmInstall(what, npm, cwd) { function npmRemove(what, npm, cwd) { return new Promise((res, rej) => { + const node = getNode() npm = npm || getNPM() cwd = cwd || getCWD() - const uninstall = spawn(npm, ['remove', '--save', what], { cwd }) + const uninstall = spawn(node, [npm, 'remove', '--save', what], { cwd }) uninstall.stdout.pipe(process.stdout) uninstall.stderr.pipe(process.stderr) @@ -105,6 +107,10 @@ function npmRemove(what, npm, cwd) { }) } +function getNode() { + return process.argv[0] +} + function getNPM() { return process.argv[0].replace(/node$/, 'npm') } diff --git a/index.js b/index.js index 607a1692930cf326a6faccb9d0366e8f29eb21f8..4b761d0c177afa620351786452e1e028cd1a43c7 100644 --- a/index.js +++ b/index.js @@ -138,12 +138,15 @@ function Stack(dependencies) { neutral: [] }; + // Part of modules API + this.getModule = (name) => loaded[name] + this.registerDependency = (requiredObject, name) => { if (name && loaded[name]) { // Do not try to load it twice return; } - loaded[name] = true; + loaded[name] = requiredObject; const def = requiredObject.duniter; definitions.push(def); for (const opt of (def.cliOptions || [])) { diff --git a/yarn.lock b/yarn.lock index e4367624b6b262d4e4b397931e46f5b370bbf5cf..b8c23c56609ff889d0d652231907b7ec84ef6986 100644 --- a/yarn.lock +++ b/yarn.lock @@ -796,8 +796,8 @@ duniter-prover@1.3.x: underscore "1.8.3" duniter-ui@1.3.x: - version "1.3.1" - resolved "https://registry.yarnpkg.com/duniter-ui/-/duniter-ui-1.3.1.tgz#cddebe90588e142c7958b986bb0e1c9f957dbe93" + version "1.3.4" + resolved "https://registry.yarnpkg.com/duniter-ui/-/duniter-ui-1.3.4.tgz#f0e969b30f5bb6076f122fdb119ffda120cf8a7c" dependencies: adm-zip "0.4.7" body-parser "1.17.1"