From d3704747e08a2bc53c854578cc30ad33d0ea2bfb Mon Sep 17 00:00:00 2001 From: Tyler Hall Date: Wed, 4 Sep 2024 16:37:58 -0400 Subject: [PATCH] refactor(cu): allow WALLET and WALLET_FILE, WALLET taking precendent --- servers/cu/src/config.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/servers/cu/src/config.js b/servers/cu/src/config.js index 6983f5198..ac4dba324 100644 --- a/servers/cu/src/config.js +++ b/servers/cu/src/config.js @@ -44,17 +44,18 @@ const serverConfigSchema = domainConfigSchema.extend({ /* eslint-disable no-throw-literal */ /** - * If the WALLET_FILE env var is defined, load the contents from the file. - * Refuse to boot the app if both or none of WALLET and WALLET_FILE are defined. + * If the WALLET is defined, then do nothing. + * + * Otherwise, check whether the WALLET_FILE env var is defined and load it contents + * as WALLET */ export const preprocessWallet = (envConfig) => { const { WALLET, WALLET_FILE, ...theRestOfTheConfig } = envConfig - // nothing to do here - if (!!WALLET && !WALLET_FILE) return envConfig + // WALLET takes precendent. nothing to do here + if (WALLET) return envConfig if (!WALLET && !WALLET_FILE) throw 'One of WALLET or WALLET_FILE is required' - if (!!WALLET && !!WALLET_FILE) throw 'Do not define both WALLET and WALLET_FILE' const walletPath = path.resolve(WALLET_FILE) if (!existsSync(walletPath)) throw `WALLET_FILE does not exist: ${walletPath}`