Skip to content

Commit

Permalink
fix: resolved faulty spinner loading after error in console (#1609)
Browse files Browse the repository at this point in the history
Co-authored-by: Souvik De <[email protected]>
  • Loading branch information
SahilDahekar and Souvikns authored Dec 29, 2024
1 parent 174b175 commit 908fb7f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 15 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 23 additions & 13 deletions src/commands/generate/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,19 +56,29 @@ export default class Models extends Command {

const s = spinner();
s.start('Generating models...');
const generatedModels = await generateModels({...flags, output}, document, logger, language as Languages);
if (output !== 'stdout') {
const generatedModelStrings = generatedModels.map((model) => { return model.modelName; });
s.stop(green(`Successfully generated the following models: ${generatedModelStrings.join(', ')}`));
return;
}
const generatedModelStrings = generatedModels.map((model) => {
return `
## Model name: ${model.modelName}
${model.result}
`;
});
s.stop(green(`Successfully generated the following models: ${generatedModelStrings.join('\n')}`));
try {
const generatedModels = await generateModels({...flags, output}, document, logger, language as Languages);
if (output !== 'stdout') {
const generatedModelStrings = generatedModels.map((model) => { return model.modelName; });
s.stop(green(`Successfully generated the following models: ${generatedModelStrings.join(', ')}`));
return;
}
const generatedModelStrings = generatedModels.map((model) => {
return `
## Model name: ${model.modelName}
${model.result}
`;
});
s.stop(green(`Successfully generated the following models: ${generatedModelStrings.join('\n')}`));
} catch (error) {
s.stop(green('Failed to generate models'));

if (error instanceof Error) {
this.error(error.message);
} else {
this.error('An unknown error occurred during model generation.');
}
}
}

private async parseArgs(args: Record<string, any>, output?: string) {
Expand Down

0 comments on commit 908fb7f

Please sign in to comment.