Show plugin (name and version) loaded (#1826)
* Print plugin name and version in devtools * Add plugins informations in About dialog
This commit is contained in:
parent
5ec705000f
commit
db35faa431
6 changed files with 61 additions and 18 deletions
|
|
@ -73,7 +73,19 @@ const clearModulesCache = () => {
|
|||
}
|
||||
};
|
||||
|
||||
const getPluginName = path => window.require('path').basename(path);
|
||||
const pathModule = window.require('path');
|
||||
|
||||
const getPluginName = path => pathModule.basename(path);
|
||||
|
||||
const getPluginVersion = path => {
|
||||
let version = null;
|
||||
try {
|
||||
version = window.require(pathModule.resolve(path, 'package.json')).version;
|
||||
} catch (err) {
|
||||
console.warn(`No package.json found in ${path}`);
|
||||
}
|
||||
return version;
|
||||
};
|
||||
|
||||
const loadModules = () => {
|
||||
console.log('(re)loading renderer plugins');
|
||||
|
|
@ -112,6 +124,7 @@ const loadModules = () => {
|
|||
.map(path => {
|
||||
let mod;
|
||||
const pluginName = getPluginName(path);
|
||||
const pluginVersion = getPluginVersion(path);
|
||||
|
||||
// window.require allows us to ensure this doesn't get
|
||||
// in the way of our build
|
||||
|
|
@ -126,6 +139,7 @@ const loadModules = () => {
|
|||
for (const i in mod) {
|
||||
if ({}.hasOwnProperty.call(mod, i)) {
|
||||
mod[i]._pluginName = pluginName;
|
||||
mod[i]._pluginVersion = pluginVersion;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -209,6 +223,8 @@ const loadModules = () => {
|
|||
mod.onRendererWindow(window);
|
||||
}
|
||||
|
||||
console.log(`Plugin ${pluginName} (${pluginVersion}) loaded.`);
|
||||
|
||||
return mod;
|
||||
})
|
||||
.filter(mod => Boolean(mod));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue