@@ -66,43 +66,41 @@ yargs(hideBin(process.argv))
66
66
( ) => configurationFileArgument ,
67
67
async ( argv ) => {
68
68
const config : ApiTypescriptGeneratorConfig = await loadConfig ( argv . config ) ;
69
- await Promise . all (
70
- config . generates . map ( async ( generateConfig ) => {
71
- switch ( generateConfig . type ) {
72
- case 'openapiClient' :
73
- const document = await loadOpenApiDocument ( generateConfig . document ) ;
74
- const files = await postprocessFiles ( {
75
- files : (
76
- await openapiToTypescriptClient ( {
77
- document,
78
- generateConfig
79
- } )
80
- ) . files ,
81
- config : generateConfig . postprocess ,
82
- outputDirPath : generateConfig . outputDirPath
83
- } ) ;
84
- const allDirectories = new Set < string > ( ) ;
85
- for ( const { filename} of files ) {
86
- allDirectories . add ( path . dirname ( path . resolve ( generateConfig . outputDirPath , filename ) ) ) ;
87
- }
88
- for ( const directoryPath of allDirectories ) {
89
- try {
90
- await fs . promises . mkdir ( directoryPath , { recursive : true } ) ;
91
- } catch ( e ) {
92
- throw new Error (
93
- `Could not create directory "${ directoryPath } ": ${ e instanceof Error ? e . message : e } .`
94
- ) ;
95
- }
69
+ for ( const generateConfig of config . generates ) {
70
+ switch ( generateConfig . type ) {
71
+ case 'openapiClient' :
72
+ const document = await loadOpenApiDocument ( generateConfig . document ) ;
73
+ const files = await postprocessFiles ( {
74
+ files : (
75
+ await openapiToTypescriptClient ( {
76
+ document,
77
+ generateConfig
78
+ } )
79
+ ) . files ,
80
+ config : generateConfig . postprocess ,
81
+ outputDirPath : generateConfig . outputDirPath
82
+ } ) ;
83
+ const allDirectories = new Set < string > ( ) ;
84
+ for ( const { filename} of files ) {
85
+ allDirectories . add ( path . dirname ( path . resolve ( generateConfig . outputDirPath , filename ) ) ) ;
86
+ }
87
+ for ( const directoryPath of allDirectories ) {
88
+ try {
89
+ await fs . promises . mkdir ( directoryPath , { recursive : true } ) ;
90
+ } catch ( e ) {
91
+ throw new Error (
92
+ `Could not create directory "${ directoryPath } ": ${ e instanceof Error ? e . message : e } .`
93
+ ) ;
96
94
}
97
- await saveGenerationResult ( {
98
- files ,
99
- outputDirPath : generateConfig . outputDirPath ,
100
- cleanupDirectories : getCleanupDirectories ( generateConfig )
101
- } ) ;
102
- break ;
103
- }
104
- } )
105
- ) ;
95
+ }
96
+ await saveGenerationResult ( {
97
+ files ,
98
+ outputDirPath : generateConfig . outputDirPath ,
99
+ cleanupDirectories : getCleanupDirectories ( generateConfig )
100
+ } ) ;
101
+ break ;
102
+ }
103
+ }
106
104
}
107
105
)
108
106
. command (
@@ -111,34 +109,32 @@ yargs(hideBin(process.argv))
111
109
( ) => configurationFileArgument ,
112
110
async ( argv ) => {
113
111
const config : ApiTypescriptGeneratorConfig = await loadConfig ( argv . config ) ;
114
- await Promise . all (
115
- config . generates . map ( async ( generateConfig ) => {
116
- switch ( generateConfig . type ) {
117
- case 'openapiClient' :
118
- if (
119
- ! ( await compareGenerationResult ( {
120
- files : await postprocessFiles ( {
121
- files : (
122
- await openapiToTypescriptClient ( {
123
- document : await loadOpenApiDocument ( generateConfig . document ) ,
124
- generateConfig
125
- } )
126
- ) . files ,
127
- config : generateConfig . postprocess ,
128
- outputDirPath : generateConfig . outputDirPath
129
- } ) ,
130
- outputDirPath : generateConfig . outputDirPath ,
131
- cleanupDirectories : getCleanupDirectories ( generateConfig )
132
- } ) )
133
- ) {
134
- console . error (
135
- 'Generated files are not up to date. Please run "api-typescript-generator generate" to update them.'
136
- ) ;
137
- process . exit ( 1 ) ;
138
- }
139
- }
140
- } )
141
- ) ;
112
+ for ( const generateConfig of config . generates ) {
113
+ switch ( generateConfig . type ) {
114
+ case 'openapiClient' :
115
+ if (
116
+ ! ( await compareGenerationResult ( {
117
+ files : await postprocessFiles ( {
118
+ files : (
119
+ await openapiToTypescriptClient ( {
120
+ document : await loadOpenApiDocument ( generateConfig . document ) ,
121
+ generateConfig
122
+ } )
123
+ ) . files ,
124
+ config : generateConfig . postprocess ,
125
+ outputDirPath : generateConfig . outputDirPath
126
+ } ) ,
127
+ outputDirPath : generateConfig . outputDirPath ,
128
+ cleanupDirectories : getCleanupDirectories ( generateConfig )
129
+ } ) )
130
+ ) {
131
+ console . error (
132
+ 'Generated files are not up to date. Please run "api-typescript-generator generate" to update them.'
133
+ ) ;
134
+ process . exit ( 1 ) ;
135
+ }
136
+ }
137
+ }
142
138
}
143
139
)
144
140
. demandCommand ( 1 )
0 commit comments