@@ -7,7 +7,7 @@ import { generateModels, Languages, ModelinaArgs } from '@asyncapi/modelina-cli'
7
7
import { modelsFlags } from '../../core/flags/generate/models.flags' ;
8
8
import { proxyFlags } from 'core/flags/proxy.flags' ;
9
9
import { HttpsProxyAgent } from 'https-proxy-agent' ;
10
- import fetch , { RequestInit } from 'node-fetch' ;
10
+ import fetch , { RequestInit , Response } from 'node-fetch' ;
11
11
12
12
export default class Models extends Command {
13
13
static description = 'Generates typed models' ;
@@ -27,7 +27,8 @@ export default class Models extends Command {
27
27
const interactive = ! flags [ 'no-interactive' ] ;
28
28
const proxyHost = flags [ 'proxyHost' ] ;
29
29
const proxyPort = flags [ 'proxyPort' ] ;
30
- let proxyAgent ;
30
+ let proxyAgent : HttpsProxyAgent < string > | undefined ;
31
+
31
32
32
33
if ( proxyHost && proxyPort ) {
33
34
const proxyUrl = `http://${ proxyHost } :${ proxyPort } ` ;
@@ -43,9 +44,12 @@ export default class Models extends Command {
43
44
output = parsedArgs . output ;
44
45
}
45
46
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
+
49
53
const inputFile = ( await load ( file ) ) || ( await load ( ) ) ;
50
54
51
55
const { document, diagnostics , status } = await parse ( this , inputFile , flags as ValidateOptions ) ;
0 commit comments