From 93094bcb7206f79c67bd69536a2ce51aeda0ddc8 Mon Sep 17 00:00:00 2001 From: trivernis Date: Wed, 27 Dec 2023 16:35:14 +0100 Subject: [PATCH] Keep only the changes to loading the config files using glob patterns --- packages/backend/src/config.ts | 29 ++++++++--------------------- 1 file changed, 8 insertions(+), 21 deletions(-) diff --git a/packages/backend/src/config.ts b/packages/backend/src/config.ts index 99a3ed0f76..24a0296aa9 100644 --- a/packages/backend/src/config.ts +++ b/packages/backend/src/config.ts @@ -183,33 +183,20 @@ const _dirname = dirname(_filename); */ const dir = `${_dirname}/../../../.config`; -function buildPath() { - const envVars = ['MISSKEY_CONFIG_YML', 'SHARKEY_CONFIG_YML', 'SHARKEY_CONFIG_FILE']; - const envCfgFile = envVars - .map(v => process.env[v]) - .map(v => v ? resolve(dir, v) : undefined) - .find(v => !!v); - - if (envCfgFile) { - return envCfgFile; - } - if (process.env.NODE_ENV === 'test') { - return resolve(dir, 'test.yml'); - } - - return resolve(dir, 'default.yml'); -} - /** - * Path of configuration file. Supports loading multiple files using glob syntax + * Path of configuration file */ -const path = buildPath(); +const path = process.env.MISSKEY_CONFIG_YML + ? resolve(dir, process.env.MISSKEY_CONFIG_YML) + : process.env.NODE_ENV === 'test' + ? resolve(dir, 'test.yml') + : resolve(dir, 'default.yml'); export function loadConfig(): Config { const meta = JSON.parse(fs.readFileSync(`${_dirname}/../../../built/meta.json`, 'utf-8')); const clientManifestExists = fs.existsSync(`${_dirname}/../../../built/_vite_/manifest.json`); - const clientManifest = clientManifestExists - ? JSON.parse(fs.readFileSync(`${_dirname}/../../../built/_vite_/manifest.json`, 'utf-8')) + const clientManifest = clientManifestExists ? + JSON.parse(fs.readFileSync(`${_dirname}/../../../built/_vite_/manifest.json`, 'utf-8')) : { 'src/_boot_.ts': { file: 'src/_boot_.ts' } }; const config = globSync(path)