use requested path to configs (#357)

This commit is contained in:
Jess Porter 2022-08-17 16:17:23 +01:00 committed by GitHub
parent 9bcb0b7a59
commit 625b62ce6d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -15,6 +15,7 @@ limitations under the License.
*/ */
import * as fs from "fs"; import * as fs from "fs";
import * as path from "path";
import { load } from "js-yaml"; import { load } from "js-yaml";
import { MatrixClient } from "matrix-bot-sdk"; import { MatrixClient } from "matrix-bot-sdk";
@ -170,7 +171,10 @@ const defaultConfig: IConfig = {
}; };
export function read(): IConfig { export function read(): IConfig {
const content = fs.readFileSync(`./config/${process.env.NODE_ENV || 'default'}.yaml`, "utf8"); const config_dir = process.env.NODE_CONFIG_DIR || "./config";
const config_file = `${process.env.NODE_ENV || "default"}.yaml`
const content = fs.readFileSync(path.join(config_dir, config_file), "utf8");
const parsed = load(content); const parsed = load(content);
const config = {...defaultConfig, ...(parsed as object)} as IConfig; const config = {...defaultConfig, ...(parsed as object)} as IConfig;
return config; return config;