cryptpad/lib/plugin-manager.js

24 lines
641 B
JavaScript
Raw Normal View History

2023-12-15 14:38:01 +00:00
// SPDX-FileCopyrightText: 2023 XWiki CryptPad Team <contact@cryptpad.org> and contributors
//
// SPDX-License-Identifier: AGPL-3.0-or-later
2023-11-17 16:19:04 +00:00
const fs = require('node:fs');
const plugins = {};
try {
let pluginsDir = fs.readdirSync(__dirname + '/plugins');
pluginsDir.forEach((name) => {
2023-12-18 09:08:52 +00:00
if (name=== "README.md") { return; }
2023-11-17 16:19:04 +00:00
try {
let plugin = require(`./plugins/${name}/index`);
plugins[plugin.name] = plugin.modules;
} catch (err) {
console.error(err);
}
});
} catch (err) {
2023-12-05 15:14:59 +00:00
if (err.code !== 'ENOENT') { console.error(err); }
2023-11-17 16:19:04 +00:00
}
module.exports = plugins;