diff --git a/src/backend/model/extension/ExtensionManager.ts b/src/backend/model/extension/ExtensionManager.ts index ab203a410..4481e4a77 100644 --- a/src/backend/model/extension/ExtensionManager.ts +++ b/src/backend/model/extension/ExtensionManager.ts @@ -12,6 +12,7 @@ import {SQLConnection} from '../database/SQLConnection'; import {ExtensionObject} from './ExtensionObject'; import {ExtensionDecoratorObject} from './ExtensionDecorator'; import * as util from 'util'; +import {ServerExtensionsEntryConfig} from '../../../common/config/private/subconfigs/ServerExtensionsConfig'; // eslint-disable-next-line @typescript-eslint/no-var-requires const exec = util.promisify(require('child_process').exec); @@ -79,6 +80,14 @@ export class ExtensionManager implements IObjectManager { ); extList.sort(); + // delete not existing extensions + Config.Extensions.extensions = Config.Extensions.extensions.filter(ec => extList.indexOf(ec.path) !== -1); + + + // Add new extensions + const ePaths = Config.Extensions.extensions.map(ec => ec.path); + extList.filter(ep => ePaths.indexOf(ep) === -1).forEach(ep => + Config.Extensions.extensions.push(new ServerExtensionsEntryConfig(ep))); Logger.debug(LOG_TAG, 'Extensions found: ', JSON.stringify(Config.Extensions.extensions.map(ec => ec.path))); } diff --git a/src/common/config/private/Config.ts b/src/common/config/private/Config.ts index 143bc5e91..e53f2a748 100644 --- a/src/common/config/private/Config.ts +++ b/src/common/config/private/Config.ts @@ -6,8 +6,12 @@ import * as path from 'path'; const pre = ConfigClassBuilder.attachPrivateInterface(new PrivateConfigClass()); try { + //NOTE: can possibly remove this saveIfNotExist hack if typeconfig issue #27 is fixed + const origSaveIfNotExist = (pre.__options as any).saveIfNotExist; + (pre.__options as any).saveIfNotExist = false; pre.loadSync(); + (pre.__options as any).saveIfNotExist = origSaveIfNotExist; } catch (e) { /* empty */ } -ExtensionConfigTemplateLoader.Instance.init(path.join(__dirname, '/../../../../', pre.Extensions.folder)); +ExtensionConfigTemplateLoader.Instance.init(pre.Extensions.folder); export const Config = ExtensionConfigWrapper.originalSync(true);