Skip to content

Commit

Permalink
fix: change envOptions to not have the keys instead of being undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
CptSchnitz committed Jun 30, 2024
1 parent 5a00dbb commit 9746d3f
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,21 @@ import { createConfigError } from './errors';

const debug = createDebug('options');

const envOptions: Record<keyof BaseOptions, string | undefined> = {
const envOptions: Partial<Record<keyof BaseOptions, string>> = {
configName: process.env.CONFIG_NAME,
configServerUrl: process.env.CONFIG_SERVER_URL,
version: process.env.CONFIG_VERSION,
offlineMode: process.env.CONFIG_OFFLINE_MODE,
ignoreServerIsOlderVersionError: process.env.CONFIG_IGNORE_SERVER_IS_OLDER_VERSION_ERROR,
};

// in order to merge correctly the keys should not exist, undefined is not enough
for (const key in envOptions) {
if (envOptions[key as keyof BaseOptions] === undefined) {
delete envOptions[key as keyof BaseOptions];
}
}

let baseOptions: BaseOptions | undefined = undefined;

export function initializeOptions(options: Partial<BaseOptions>): BaseOptions {
Expand Down

0 comments on commit 9746d3f

Please sign in to comment.