plugins: use user env vars for npm install (#172)

This commit is contained in:
Marc Bachmann 2016-07-17 19:28:24 +02:00 committed by Guillermo Rauch
parent 3d7f6fa060
commit 1e1b31aad8
2 changed files with 11 additions and 7 deletions

View file

@ -14,6 +14,7 @@
"gaze": "1.1.0",
"mkdirp": "0.5.1",
"ms": "0.7.1",
"shell-env": "0.1.2",
"uid2": "0.0.3"
},
"devDependencies": {

View file

@ -8,6 +8,7 @@ const { exec } = require('child_process');
const Config = require('electron-config');
const ms = require('ms');
const notify = require('./notify');
const shellEnv = require('shell-env');
// local storage
const cache = new Config();
@ -189,13 +190,15 @@ function toDependencies (plugins) {
}
function install (fn) {
const prefix = 'darwin' === process.platform ? 'eval `/usr/libexec/path_helper -s` && ' : '';
exec(prefix + 'npm prune && npm install --production', {
cwd: path
shellEnv().then((env) => {
exec('npm prune && npm install --production', {
cwd: path,
env: env
}, (err, stdout, stderr) => {
if (err) return fn(err);
fn(null);
});
}).catch(fn);
}
exports.subscribe = function (fn) {