@@ -10,6 +10,7 @@ const defaultSchema = { type: "object", additionalProperties: false };
10
10
export interface Options {
11
11
glob : string ;
12
12
prefix : string ;
13
+ ext : string ;
13
14
}
14
15
15
16
export async function generateReplyInterfaces (
@@ -86,9 +87,16 @@ export { ${options.prefix}Handler, schema }\
86
87
` ;
87
88
}
88
89
89
- async function writeFile ( parsedPath : path . ParsedPath , template : string ) {
90
+ async function writeFile (
91
+ parsedPath : path . ParsedPath ,
92
+ template : string ,
93
+ options : Options
94
+ ) {
90
95
const write = promisify ( fs . writeFile ) ;
91
- return write ( path . join ( parsedPath . dir , parsedPath . name + ".ts" ) , template ) ;
96
+ return write (
97
+ path . join ( parsedPath . dir , parsedPath . name + options . ext ) ,
98
+ template
99
+ ) ;
92
100
}
93
101
94
102
export async function convert ( options : Options ) {
@@ -97,6 +105,6 @@ export async function convert(options: Options) {
97
105
const parsedPath = path . parse ( filePath ) ;
98
106
const schema = JSON . parse ( fs . readFileSync ( filePath , "utf-8" ) ) ;
99
107
const template = await generateInterfaces ( parsedPath , schema , options ) ;
100
- await writeFile ( parsedPath , template ) ;
108
+ await writeFile ( parsedPath , template , options ) ;
101
109
}
102
110
}
0 commit comments