CONFIG_FILE => CONFIG_PATH
| @@ -23,7 +23,7 @@ import { serverDirectory } from './server-directory.js'; | ||
| 23 | 23 | * Parsed config object. |
| 24 | 24 | */ |
| 25 | 25 | let CACHED_CONFIG = null; |
| 26 | 26 | let CONFIG_FILECONFIG_PATH = null; |
| 27 | 27 | |
| 28 | 28 | /** |
| 29 | 29 | * Converts a configuration key to an environment variable key. |
| @@ -38,10 +38,10 @@ export const keyToEnv = (key) => 'SILLYTAVERN_' + String(key).toUpperCase().repl | ||
| 38 | 38 | * @param {string} configFilePath Path to the config file |
| 39 | 39 | */ |
| 40 | 40 | export function setConfigFilePath(configFilePath) { |
| 41 | 41 | if (CONFIG_FILECONFIG_PATH !== null) { |
| 42 | 42 | console.error(color.red('Config file path already set. Please restart the server to change the config file path.')); |
| 43 | 43 | } |
| 44 | 44 | CONFIG_FILECONFIG_PATH = path.resolve(configFilePath); |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | /** |
| @@ -49,7 +49,7 @@ export function setConfigFilePath(configFilePath) { | ||
| 49 | 49 | * @returns {object} Config object |
| 50 | 50 | */ |
| 51 | 51 | export function getConfig() { |
| 52 | 52 | if (CONFIG_FILECONFIG_PATH === null) { |
| 53 | 53 | console.trace(); |
| 54 | 54 | console.error(color.red('No config file path set. Please set the config file path using setConfigFilePath().')); |
| 55 | 55 | process.exit(1); |
| @@ -57,14 +57,14 @@ export function getConfig() { | ||
| 57 | 57 | if (CACHED_CONFIG) { |
| 58 | 58 | return CACHED_CONFIG; |
| 59 | 59 | } |
| 60 | 60 | if (!fs.existsSync(CONFIG_FILECONFIG_PATH)) { |
| 61 | 61 | console.error(color.red('No config file found. Please create a config.yaml file. The default config file can be found in the /default folder.')); |
| 62 | 62 | console.error(color.red('The program will now exit.')); |
| 63 | 63 | process.exit(1); |
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | try { |
| 67 | 67 | const config = yaml.parse(fs.readFileSync(CONFIG_FILECONFIG_PATH, 'utf8')); |
| 68 | 68 | CACHED_CONFIG = config; |
| 69 | 69 | return config; |
| 70 | 70 | } catch (error) { |