Skip to content

Commit

Permalink
fix(config.ts): improve error message for invalid config keys
Browse files Browse the repository at this point in the history
- Enhanced the error message to provide a more accurate suggestion for invalid config keys.
- The message now dynamically suggests the correct key format by checking if the key starts with 'GW_' and appending it if necessary.
- This change improves user guidance and helps in quicker resolution of configuration issues.
  • Loading branch information
SHSharkar committed Aug 16, 2024
1 parent 6f9adbe commit 0a6d784
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/commands/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,9 +204,8 @@ export const getConfig = (): ConfigType | null => {
const validator = configValidators[configKey as CONFIG_KEYS];
config[configKey] = validator(config[configKey] ?? configFromEnv[configKey as CONFIG_KEYS], config);
} catch (error) {
outro(
`'${configKey}' name is invalid, it should be either 'GW_${configKey.toUpperCase()}' or it doesn't exist.`,
);
const suggestedKey = configKey.startsWith('GW_') ? configKey : `GW_${configKey}`;
outro(`'${configKey}' name is invalid, it should be '${suggestedKey}' or it doesn't exist.`);
outro(`Manually fix the '.env' file or global '~/.gitwz' config file.`);
process.exit(1);
}
Expand Down

0 comments on commit 0a6d784

Please sign in to comment.