Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: print in cli asyncapi generate models without -o flag #1664

Merged
merged 9 commits into from
Feb 18, 2025
5 changes: 5 additions & 0 deletions .changeset/sour-clouds-heal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@asyncapi/cli": patch
---

fix: print in cli asyncapi generate models without -o flag
2 changes: 1 addition & 1 deletion src/commands/generate/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export default class Models extends Command {
s.start('Generating models...');
try {
const generatedModels = await generateModels({...flags, output}, document, logger, language as Languages);
if (output !== 'stdout') {
if (output && output !== 'stdout') {
const generatedModelStrings = generatedModels.map((model) => { return model.modelName; });
s.stop(green(`Successfully generated the following models: ${generatedModelStrings.join(', ')}`));
return;
Expand Down
13 changes: 11 additions & 2 deletions test/integration/generate/models.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,21 @@ describe('models', () => {
);
done();
});


test
.stderr()
.stdout()
.command([...generalOptions, 'typescript', './test/fixtures/specification.yml'])
.it('works when file path is passed without specified output directory', (ctx, done) => {
expect(ctx.stdout).to.match(/Successfully generated the following models:\s+## Model name:/);
done();
});

test
.stderr()
.stdout()
.command([...generalOptions, 'typescript', './test/fixtures/specification.yml', `-o=${ path.resolve(outputDir, './ts')}`])
.it('works when file path is passed', (ctx, done) => {
.it('works when file path is passed with specified output directory', (ctx, done) => {
expect(ctx.stdout).to.contain(
'Successfully generated the following models: '
);
Expand Down
Loading