Skip to content

Commit

Permalink
Resolved the spinner loading even after error in console
Browse files Browse the repository at this point in the history
  • Loading branch information
SahilDahekar committed Dec 23, 2024
1 parent da64c63 commit 3d9be13
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"));

Check failure on line 74 in src/commands/generate/models.ts

View workflow job for this annotation

GitHub Actions / Test NodeJS PR - ubuntu-latest

Strings must use singlequote

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 3d9be13

Please sign in to comment.