Skip to content

Commit

Permalink
#63 fix plugin-manager plugin scan
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefan Werfling committed Feb 29, 2024
1 parent d2fec4f commit 110f79c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
8 changes: 6 additions & 2 deletions backend/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,12 @@ import exitHook from 'async-exit-hook';

// load plugins ----------------------------------------------------------------------------------------------------

const pm = new PluginManager('backend', path.resolve());
await pm.start();
try {
const pm = new PluginManager('backend', path.resolve());
await pm.start();
} catch (error) {
Logger.getLogger().error('The plugin manager could not load the plugins.', error);
}

// -----------------------------------------------------------------------------------------------------------------

Expand Down
8 changes: 6 additions & 2 deletions core/src/inc/PluginSystem/PluginManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,14 @@ export class PluginManager {
* @returns {PluginInformation[]}
*/
public scan(): PluginInformation[] {
const nodeModulesPath = path.join(this._appPath, 'node_modules');
let nodeModulesPath = path.join(this._appPath, 'node_modules');

if (!fs.existsSync(nodeModulesPath)) {
throw new Error(`node_modules directory not found: ${nodeModulesPath}`);
nodeModulesPath = path.join(this._appPath, 'node_modules', this._serviceName);

if (!fs.existsSync(nodeModulesPath)) {
throw new Error(`node_modules directory not found: ${nodeModulesPath}`);
}
}

const modules = fs.readdirSync(nodeModulesPath);
Expand Down

0 comments on commit 110f79c

Please sign in to comment.