Skip to content

Commit 32b7262

Browse files
fix(cli): handle empty AsyncAPI file gracefully
1 parent 77b504e commit 32b7262

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/apps/cli/commands/generate/fromTemplate.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,20 @@ export default class Template extends BaseGeneratorCommand {
5959

6060
const asyncapiInput = await this.loadAsyncAPIInput(asyncapi);
6161

62+
const content =
63+
typeof asyncapiInput === 'string'
64+
? asyncapiInput
65+
: asyncapiInput?.toString?.() ?? '';
66+
67+
if (content.trim().length === 0) {
68+
return this.error(
69+
new ValidationError({
70+
type: 'invalid-file',
71+
filepath: asyncapi,
72+
}),
73+
{ exit: 1 },
74+
);
75+
}
6276
this.specFile = asyncapiInput;
6377
this.metricsMetadata.template = template;
6478

0 commit comments

Comments
 (0)