plugins: detect location of npm

This commit is contained in:
Guillermo Rauch 2016-07-08 07:40:57 -07:00
parent edc201ea03
commit 3eb50ca946

View file

@ -166,11 +166,8 @@ function toDependencies (plugins) {
} }
function install (fn) { function install (fn) {
exec('npm prune && npm install --production', { which('npm', (err, bin) => {
cwd: path
}, (err, stdout, stderr) => {
if (err) { if (err) {
if (/(command not found|not recognized as an)/.test(err.stack)) {
if (plugins.plugins.length) { if (plugins.plugins.length) {
alert('We found `plugins` in `.hyperterm.js`, but `npm` is ' + alert('We found `plugins` in `.hyperterm.js`, but `npm` is ' +
'not installed or not in $PATH!\nPlease head to ' + 'not installed or not in $PATH!\nPlease head to ' +
@ -178,11 +175,16 @@ function install (fn) {
} else { } else {
console.log('npm not found, but no plugins defined'); console.log('npm not found, but no plugins defined');
} }
}
return fn(err); return fn(err);
} }
exec(`${bin} prune && ${bin} install --production`, {
cwd: path
}, (err, stdout, stderr) => {
if (err) return fn(err);
fn(null); fn(null);
}); });
});
} }
exports.subscribe = function (fn) { exports.subscribe = function (fn) {