Skip to content

Commit 2deeb36

Browse files
Adi-204asyncapi-botAayushSaini101
authored
fix: print in cli asyncapi generate models without -o flag (#1664)
Co-authored-by: Adi-204 <adiboghawala@gmail.com> Co-authored-by: asyncapi-bot <bot+chan@asyncapi.io> Co-authored-by: Moderator <60972989+AayushSaini101@users.noreply.github.com>
1 parent 083fe1b commit 2deeb36

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

.changeset/sour-clouds-heal.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@asyncapi/cli": patch
3+
---
4+
5+
fix: print in cli asyncapi generate models without -o flag

src/commands/generate/models.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export default class Models extends Command {
6767
s.start('Generating models...');
6868
try {
6969
const generatedModels = await generateModels({...flags, output}, document, logger, language as Languages);
70-
if (output !== 'stdout') {
70+
if (output && output !== 'stdout') {
7171
const generatedModelStrings = generatedModels.map((model) => { return model.modelName; });
7272
s.stop(green(`Successfully generated the following models: ${generatedModelStrings.join(', ')}`));
7373
return;

test/integration/generate/models.test.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,21 @@ describe('models', () => {
2424
);
2525
done();
2626
});
27-
27+
28+
test
29+
.stderr()
30+
.stdout()
31+
.command([...generalOptions, 'typescript', './test/fixtures/specification.yml'])
32+
.it('works when file path is passed without specified output directory', (ctx, done) => {
33+
expect(ctx.stdout).to.match(/Successfully generated the following models:\s+## Model name:/);
34+
done();
35+
});
36+
2837
test
2938
.stderr()
3039
.stdout()
3140
.command([...generalOptions, 'typescript', './test/fixtures/specification.yml', `-o=${ path.resolve(outputDir, './ts')}`])
32-
.it('works when file path is passed', (ctx, done) => {
41+
.it('works when file path is passed with specified output directory', (ctx, done) => {
3342
expect(ctx.stdout).to.contain(
3443
'Successfully generated the following models: '
3544
);

0 commit comments

Comments
 (0)