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