@@ -12,7 +12,6 @@ const changeCase = require("change-case");
12
12
13
13
const timeLog = `✨ ${ name } ` ;
14
14
const defaultOutputDir = "./api" ;
15
- const changeAlways = [ "index.js" , "index.d.ts" ] ;
16
15
17
16
program
18
17
. version ( version )
@@ -110,7 +109,10 @@ async function main(config) {
110
109
resolveLocalPresets ( omitUndefined ( config ) ) ,
111
110
) ;
112
111
const apiResult = await swaggerToJs ( compiledConfig ) ;
113
- const outputFiles = buildFiles ( apiResult , compiledConfig ) ;
112
+ const { all : outputFiles , source : sourceFilesNames } = buildFiles (
113
+ apiResult ,
114
+ compiledConfig ,
115
+ ) ;
114
116
115
117
// Check and create output dir
116
118
const pathOutputDir = path . resolve ( process . cwd ( ) , compiledConfig . outputDir ) ;
@@ -120,7 +122,7 @@ async function main(config) {
120
122
}
121
123
122
124
// Write files
123
- writeFilesSync ( outputFiles , pathOutputDir ) ;
125
+ writeFilesSync ( outputFiles , sourceFilesNames , pathOutputDir ) ;
124
126
125
127
console . timeEnd ( timeLog ) ;
126
128
}
@@ -183,7 +185,7 @@ function buildFiles({ code, types, swaggerData }, config = {}) {
183
185
) ;
184
186
}
185
187
186
- return files ;
188
+ return { all : files , source : [ nameCode , nameTypes ] } ;
187
189
}
188
190
189
191
function resolveLocalPresets ( config ) {
@@ -219,7 +221,11 @@ function exportOneFunction(content) {
219
221
return contentLines . join ( "\n" ) ;
220
222
}
221
223
222
- function writeFilesSync ( files , outputDir = "" ) {
224
+ function writeFilesSync (
225
+ files ,
226
+ changeAlways = [ "index.d.ts" , "index.js" ] ,
227
+ outputDir = "" ,
228
+ ) {
223
229
Object . keys ( files ) . forEach ( ( fileName ) => {
224
230
const filePath = path . resolve ( outputDir , fileName ) ;
225
231
@@ -229,7 +235,7 @@ function writeFilesSync(files, outputDir = "") {
229
235
writeFileSync ( filePath , fileConfig . content ) ;
230
236
231
237
if ( fileConfig . dependencies ) {
232
- writeFilesSync ( fileConfig . dependencies , outputDir ) ;
238
+ writeFilesSync ( fileConfig . dependencies , changeAlways , outputDir ) ;
233
239
}
234
240
}
235
241
} ) ;
0 commit comments