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) { if (err) {
//eslint-disable-next-line no-console //eslint-disable-next-line no-console
console.error(err.stack); notify('Error updating plugins.', err);
notify('Error updating plugins.', err.message);
} else { } else {
// flag successful plugin update // flag successful plugin update
cache.set('hyper.plugins', id_); 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'); console.log('plugins have changed / not init, scheduling plugins installation');
setTimeout(() => { setTimeout(() => {
updatePlugins(); updatePlugins();
}, 5000); }, 1000);
} }
// otherwise update plugins every 5 hours // otherwise update plugins every 5 hours
@ -243,9 +242,14 @@ function requirePlugins() {
return mod; return mod;
} catch (err) { } catch (err) {
//eslint-disable-next-line no-console if (err.code === 'MODULE_NOT_FOUND') {
console.error(err); //eslint-disable-next-line no-console
notify('Plugin error!', `Plugin "${basename(path_)}" failed to load (${err.message})`); 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'), timeout: ms('5m'),
maxBuffer: 1024 * 1024 maxBuffer: 1024 * 1024
}, },
err => { (err, stdout, stderr) => {
if (err) { if (err) {
cb(err); cb(stderr);
} else { } else {
cb(null); cb(null);
} }

View file

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