Skip to content

Conversation

shamsartem
Copy link
Contributor

No description provided.

@MixailE MixailE self-requested a review November 18, 2024 13:00
}
} catch {
if (getDefaultConfig === undefined) {
const defaultConfigString = await getDefaultConfigString();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we avoid the nested try/catch?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

discussed privately that we currently don't know any radically better way to implement this logic

// if config file is empty for some reason - try using default
if (configString.trim() === "") {
dbg(`Config at ${actualConfigPath} is empty. Using default config`);
const defaultConfigString = await getDefaultConfigString();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same logic happens in catch

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah. Decided not to move this 3 lines to a separate function or something, arguably it would be less readable in this case

@shamsartem shamsartem merged commit f8e2e29 into main Nov 18, 2024
9 checks passed
@shamsartem shamsartem deleted the use-default-when-empty branch November 18, 2024 14:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants