Pass deps to plugins directly. Should be used when a plugin must have a module to function.
This commit is contained in:
parent
4fba4049e1
commit
b23a5ba7ac
|
@ -154,7 +154,7 @@ export default class {
|
|||
mainPath
|
||||
}
|
||||
|
||||
const content = await this.loadContent(paths, configs, readConfig.info, readConfig.main);
|
||||
const content = await this.loadContent(paths, configs, readConfig.info, readConfig.main, readConfig.dependencies);
|
||||
if (reload) this.localContent[index] = content;
|
||||
else this.localContent.push(content);
|
||||
return content;
|
||||
|
|
|
@ -56,7 +56,7 @@ export default class extends ContentManager {
|
|||
'message': `Dependency: ${key}:${value} is not loaded`
|
||||
};
|
||||
}
|
||||
deps.push(extModule);
|
||||
deps[key] = extModule.__require;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -9,6 +9,9 @@
|
|||
},
|
||||
"main": "index.js",
|
||||
"type": "plugin",
|
||||
"dependencies": {
|
||||
"Example Module": "1.0"
|
||||
},
|
||||
"defaultConfig": [
|
||||
{
|
||||
"category_default_comment": "default category has no header and is always displayed first",
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
module.exports = (Plugin, Api, Vendor) => {
|
||||
module.exports = (Plugin, Api, Vendor, Dependencies) => {
|
||||
|
||||
const { $, moment, _ } = Vendor;
|
||||
const { Events, Logger } = Api;
|
||||
|
@ -21,7 +21,7 @@ module.exports = (Plugin, Api, Vendor) => {
|
|||
console.log('Received internal setting update:', event);
|
||||
});
|
||||
|
||||
const exampleModule = new (Api.import('Example Module'));
|
||||
const exampleModule = new Dependencies['Example Module'];
|
||||
Logger.log(`2+4=${exampleModule.add(2, 4)}`);
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue