Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 8 additions & 11 deletions src/apps/cli/commands/generate/fromTemplate.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Args } from '@oclif/core';
import { BaseGeneratorCommand } from '@cli/internal/base/BaseGeneratorCommand';
import { load, Specification } from '@models/SpecificationFile';
import { Specification } from '@models/SpecificationFile';
import { ValidationError } from '@errors/validation-error';
import { GeneratorError } from '@errors/generator-error';
import { intro } from '@clack/prompts';
Expand Down Expand Up @@ -57,28 +57,25 @@ export default class Template extends BaseGeneratorCommand {
// Apply proxy configuration using base class method
asyncapi = this.applyProxyConfiguration(asyncapi, proxyHost, proxyPort);

const asyncapiInput = await this.loadAsyncAPIInput(asyncapi);

this.specFile = asyncapiInput;
this.metricsMetadata.template = template;

const watchTemplate = flags['watch'];
const genOption = this.buildGenOption(flags, parsedFlags);

let specification: Specification;
try {
specification = await load(asyncapi);
specification = await this.loadAsyncAPIInput(asyncapi);
} catch {
return this.error(
new ValidationError({

type: 'invalid-file',
filepath: asyncapi,
}),
{ exit: 1 },
);
}

this.specFile = specification;
this.metricsMetadata.template = template;

const watchTemplate = flags['watch'];
const genOption = this.buildGenOption(flags, parsedFlags);

const result = await this.generatorService.generate(
specification,
template,
Expand Down
Loading