Fixed installing of local packages.

This commit is contained in:
SamTV12345 2024-01-30 22:27:31 +01:00
parent 31dd3a6690
commit a7f81e824a

View file

@ -9,6 +9,7 @@ const axios = require('axios');
const {PluginManager} = require("live-plugin-manager");
const {promises: fs} = require("fs");
const path = require("path");
const {findEtherpadRoot} = require("../../../node/utils/AbsolutePaths");
const logger = log4js.getLogger('plugins');
exports.manager = new PluginManager();
@ -50,17 +51,22 @@ const migratePluginsFromNodeModules = async () => {
const {dependencies = {}} = JSON.parse(await runCmd(cmd, {stdio: [null, 'string']}));
await Promise.all(Object.entries(dependencies).map(async ([pkg, info]) => {
if (pkg.startsWith(plugins.prefix) && pkg !== 'ep_etherpad-lite') {
await exports.manager.install(pkg)
if (!info._resolved) {
// Install from node_modules directory
await exports.manager.installFromPath(`${findEtherpadRoot()}/src/node_modules/${pkg}`);
} else {
await exports.manager.install(pkg);
}
}
}));
await persistInstalledPlugins();
}
};
exports.checkForMigration = async () => {
logger.info('check installed plugins for migration')
logger.info('check installed plugins for migration');
try {
await fs.access(installedPluginsPath, fs.constants.F_OK)
await fs.access(installedPluginsPath, fs.constants.F_OK);
} catch (err) {
await migratePluginsFromNodeModules();
}