Skip to content

Commit e5f17af

Browse files
committed
updated models.ts
1 parent 7639803 commit e5f17af

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/commands/generate/models.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { generateModels, Languages, ModelinaArgs } from '@asyncapi/modelina-cli'
77
import { modelsFlags } from '../../core/flags/generate/models.flags';
88
import { proxyFlags } from 'core/flags/proxy.flags';
99
import { HttpsProxyAgent } from 'https-proxy-agent';
10-
import fetch, { RequestInit } from 'node-fetch';
10+
import fetch, { RequestInit, Response } from 'node-fetch';
1111

1212
export default class Models extends Command {
1313
static description = 'Generates typed models';
@@ -27,7 +27,8 @@ export default class Models extends Command {
2727
const interactive = !flags['no-interactive'];
2828
const proxyHost = flags['proxyHost'];
2929
const proxyPort = flags['proxyPort'];
30-
let proxyAgent;
30+
let proxyAgent: HttpsProxyAgent<string> | undefined;
31+
3132

3233
if (proxyHost && proxyPort) {
3334
const proxyUrl = `http://${proxyHost}:${proxyPort}`;
@@ -43,9 +44,12 @@ export default class Models extends Command {
4344
output = parsedArgs.output;
4445
}
4546

46-
const customFetch = proxyAgent
47-
? (url: string, options: RequestInit = {}) => fetch(url, { ...options, agent: proxyAgent })
48-
: fetch;
47+
const customFetch = (url: string, options: RequestInit = {}): Promise<Response> => {
48+
return proxyAgent
49+
? fetch(url, { ...options, agent: proxyAgent })
50+
: fetch(url, options);
51+
};
52+
4953
const inputFile = (await load(file)) || (await load());
5054

5155
const { document, diagnostics ,status } = await parse(this, inputFile, flags as ValidateOptions);

0 commit comments

Comments
 (0)