Enhance plugin installation (#2440)

This commit is contained in:
CHaBou 2017-11-08 22:24:15 +01:00 committed by GitHub
parent 97308bd8e5
commit 3a3ee013f7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 8 deletions

View file

@ -57,8 +57,7 @@ function updatePlugins({force = false} = {}) {
if (err) {
//eslint-disable-next-line no-console
console.error(err.stack);
notify('Error updating plugins.', err.message);
notify('Error updating plugins.', err);
} else {
// flag successful plugin update
cache.set('hyper.plugins', id_);
@ -135,7 +134,7 @@ if (cache.get('hyper.plugins') !== id || process.env.HYPER_FORCE_UPDATE) {
console.log('plugins have changed / not init, scheduling plugins installation');
setTimeout(() => {
updatePlugins();
}, 5000);
}, 1000);
}
// otherwise update plugins every 5 hours
@ -243,9 +242,14 @@ function requirePlugins() {
return mod;
} catch (err) {
//eslint-disable-next-line no-console
console.error(err);
notify('Plugin error!', `Plugin "${basename(path_)}" failed to load (${err.message})`);
if (err.code === 'MODULE_NOT_FOUND') {
//eslint-disable-next-line no-console
console.warn(`Plugin "${basename(path_)}" not found: ${path_}`);
} else {
//eslint-disable-next-line no-console
console.error(err);
notify('Plugin error!', `Plugin "${basename(path_)}" failed to load (${err.message})`);
}
}
};

View file

@ -25,9 +25,9 @@ module.exports = {
timeout: ms('5m'),
maxBuffer: 1024 * 1024
},
err => {
(err, stdout, stderr) => {
if (err) {
cb(err);
cb(stderr);
} else {
cb(null);
}

View file

@ -123,8 +123,10 @@ const loadModules = () => {
reduceTermGroups: termGroupsReducers
};
const loadedPlugins = plugins.getLoadedPluginVersions().map(plugin => plugin.name);
modules = paths.plugins
.concat(paths.localPlugins)
.filter(plugin => loadedPlugins.indexOf(plugin) !== -1)
.map(path => {
let mod;
const pluginName = getPluginName(path);