diff --git a/src/commands/bundle.ts b/src/commands/bundle.ts index b9eba5a5f2a..1ec94769440 100644 --- a/src/commands/bundle.ts +++ b/src/commands/bundle.ts @@ -57,7 +57,7 @@ export default class Bundle extends Command { } if (format === '.json') { - await writeFile(path.resolve(process.cwd(), output), document.json(), { + await writeFile(path.resolve(process.cwd(), output), document.string(), { encoding: 'utf-8', }); } diff --git a/test/commands/bundle/bundle.test.ts b/test/commands/bundle/bundle.test.ts index 870a1d590cb..170a0819be8 100644 --- a/test/commands/bundle/bundle.test.ts +++ b/test/commands/bundle/bundle.test.ts @@ -25,6 +25,20 @@ describe('bundle', () => { done(); }); + test + .stdout() + .command([ + 'bundle', './test/commands/bundle/first-asyncapi.yaml', + '--output=./test/commands/bundle/final.json' + ]) + .it('should successfully bundle specification into json file', (ctx, done) => { + expect(ctx.stdout).toContain( + 'Check out your shiny new bundled files at ./test/commands/bundle/final.json' + ); + fileCleanup('./test/commands/bundle/final.json'); + done(); + }); + test .stderr() .command([