mirror of
https://github.com/quine-global/hyper.git
synced 2026-01-15 05:08:41 -09:00
plugins: fix use of #, improve notifications, better errors
This commit is contained in:
parent
4a59c13c77
commit
60f0887c2a
2 changed files with 20 additions and 25 deletions
5
index.js
5
index.js
|
|
@ -171,11 +171,6 @@ app.on('ready', () => {
|
||||||
const pluginsUnsubscribe = plugins.subscribe((err, { force }) => {
|
const pluginsUnsubscribe = plugins.subscribe((err, { force }) => {
|
||||||
if (!err) {
|
if (!err) {
|
||||||
load();
|
load();
|
||||||
if (force) {
|
|
||||||
win.webContents.send('plugins reload');
|
|
||||||
} else {
|
|
||||||
win.webContents.send('plugins change');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
40
plugins.js
40
plugins.js
|
|
@ -7,7 +7,6 @@ const { sync: mkdirpSync } = require('mkdirp');
|
||||||
const { exec } = require('child_process');
|
const { exec } = require('child_process');
|
||||||
const Config = require('electron-config');
|
const Config = require('electron-config');
|
||||||
const ms = require('ms');
|
const ms = require('ms');
|
||||||
const which = require('which');
|
|
||||||
const notify = require('./notify');
|
const notify = require('./notify');
|
||||||
|
|
||||||
// local storage
|
// local storage
|
||||||
|
|
@ -58,6 +57,7 @@ function updatePlugins ({ force = false } = {}) {
|
||||||
updating = false;
|
updating = false;
|
||||||
|
|
||||||
if (err) {
|
if (err) {
|
||||||
|
console.error(err.stack);
|
||||||
notify(
|
notify(
|
||||||
'Error updating plugins.',
|
'Error updating plugins.',
|
||||||
'Check `~/.hyperterm_modules/npm-debug.log` for more information.'
|
'Check `~/.hyperterm_modules/npm-debug.log` for more information.'
|
||||||
|
|
@ -83,6 +83,17 @@ function updatePlugins ({ force = false } = {}) {
|
||||||
|
|
||||||
// notify watchers
|
// notify watchers
|
||||||
if (force || changed) {
|
if (force || changed) {
|
||||||
|
if (changed) {
|
||||||
|
notify(
|
||||||
|
'Plugins Updated',
|
||||||
|
'Restart the app or hot-reload with "Plugins" > "Reload Now" to enjoy the updates!'
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
notify(
|
||||||
|
'Plugins Updated',
|
||||||
|
'No changes!'
|
||||||
|
);
|
||||||
|
}
|
||||||
watchers.forEach((fn) => fn(err, { force }));
|
watchers.forEach((fn) => fn(err, { force }));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -165,24 +176,13 @@ function toDependencies (plugins) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function install (fn) {
|
function install (fn) {
|
||||||
which('npm', (err, bin) => {
|
const prefix = 'darwin' === process.platform ? 'eval `/usr/libexec/path_helper -s` && ' : '';
|
||||||
if (err) {
|
exec(prefix + 'npm prune && npm install --production', {
|
||||||
if (plugins.plugins.length) {
|
cwd: path
|
||||||
alert('We found `plugins` in `.hyperterm.js`, but `npm` is ' +
|
}, (err, stdout, stderr) => {
|
||||||
'not installed or not in $PATH!\nPlease head to ' +
|
if (err) alert(err.stack);
|
||||||
'https://nodejs.org and install the Node.js runtime.');
|
if (err) return fn(err);
|
||||||
} else {
|
fn(null);
|
||||||
console.log('npm not found, but no plugins defined');
|
|
||||||
}
|
|
||||||
return fn(err);
|
|
||||||
}
|
|
||||||
|
|
||||||
exec(`${bin} prune && ${bin} install --production`, {
|
|
||||||
cwd: path
|
|
||||||
}, (err, stdout, stderr) => {
|
|
||||||
if (err) return fn(err);
|
|
||||||
fn(null);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -196,7 +196,7 @@ exports.subscribe = function (fn) {
|
||||||
function getPaths () {
|
function getPaths () {
|
||||||
return {
|
return {
|
||||||
plugins: plugins.plugins.map((name) => {
|
plugins: plugins.plugins.map((name) => {
|
||||||
return resolve(path, 'node_modules', name);
|
return resolve(path, 'node_modules', name.split('#')[0]);
|
||||||
}),
|
}),
|
||||||
localPlugins: plugins.localPlugins.map((name) => {
|
localPlugins: plugins.localPlugins.map((name) => {
|
||||||
return resolve(localPath, name);
|
return resolve(localPath, name);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue