From 1e1b31aad8242ffbd22ca6bce9c9a5d2a3c88b2d Mon Sep 17 00:00:00 2001 From: Marc Bachmann Date: Sun, 17 Jul 2016 19:28:24 +0200 Subject: [PATCH] plugins: use user env vars for `npm install` (#172) --- package.json | 1 + plugins.js | 17 ++++++++++------- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index f80f19e1..ca7af456 100644 --- a/package.json +++ b/package.json @@ -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": { diff --git a/plugins.js b/plugins.js index 1ae97174..89e3dca5 100644 --- a/plugins.js +++ b/plugins.js @@ -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 - }, (err, stdout, stderr) => { - if (err) return fn(err); - fn(null); - }); + 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) {