@@ -35,8 +35,8 @@ const getSchema = ({
35
35
return file ;
36
36
} ;
37
37
38
- const getPath = ( path : string , name : string ) : string =>
39
- upath . join ( path , `/${ name } .ts ` ) ;
38
+ const getPath = ( path : string , name : string , fileExtension : string ) : string =>
39
+ upath . join ( path , `/${ name } ${ fileExtension } ` ) ;
40
40
41
41
export const writeModelInline = ( acc : string , model : string ) : string =>
42
42
acc + `${ model } \n` ;
@@ -48,6 +48,7 @@ export const writeSchema = async ({
48
48
path,
49
49
schema,
50
50
target,
51
+ fileExtension,
51
52
specKey,
52
53
isRootKey,
53
54
specsName,
@@ -56,6 +57,7 @@ export const writeSchema = async ({
56
57
path : string ;
57
58
schema : GeneratorSchema ;
58
59
target : string ;
60
+ fileExtension : string ;
59
61
specKey : string ;
60
62
isRootKey : boolean ;
61
63
specsName : Record < string , string > ;
@@ -65,7 +67,7 @@ export const writeSchema = async ({
65
67
66
68
try {
67
69
await fs . outputFile (
68
- getPath ( path , name ) ,
70
+ getPath ( path , name , fileExtension ) ,
69
71
getSchema ( { schema, target, isRootKey, specsName, header, specKey } ) ,
70
72
) ;
71
73
} catch ( e ) {
@@ -77,6 +79,7 @@ export const writeSchemas = async ({
77
79
schemaPath,
78
80
schemas,
79
81
target,
82
+ fileExtension,
80
83
specKey,
81
84
isRootKey,
82
85
specsName,
@@ -86,6 +89,7 @@ export const writeSchemas = async ({
86
89
schemaPath : string ;
87
90
schemas : GeneratorSchema [ ] ;
88
91
target : string ;
92
+ fileExtension : string ;
89
93
specKey : string ;
90
94
isRootKey : boolean ;
91
95
specsName : Record < string , string > ;
@@ -98,6 +102,7 @@ export const writeSchemas = async ({
98
102
path : schemaPath ,
99
103
schema,
100
104
target,
105
+ fileExtension,
101
106
specKey,
102
107
isRootKey,
103
108
specsName,
@@ -107,7 +112,7 @@ export const writeSchemas = async ({
107
112
) ;
108
113
109
114
if ( indexFiles ) {
110
- const schemaFilePath = upath . join ( schemaPath , ' /index.ts' ) ;
115
+ const schemaFilePath = upath . join ( schemaPath , ` /index${ fileExtension } ` ) ;
111
116
await fs . ensureFile ( schemaFilePath ) ;
112
117
113
118
// Ensure separate files are used for parallel schema writing.
@@ -139,14 +144,22 @@ export const writeSchemas = async ({
139
144
140
145
const stringData = data . toString ( ) ;
141
146
147
+ const ext = fileExtension . endsWith ( '.ts' )
148
+ ? fileExtension . slice ( 0 , - 3 )
149
+ : fileExtension ;
150
+
142
151
const importStatements = schemas
143
152
. filter ( ( schema ) => {
144
153
return (
145
- ! stringData . includes ( `export * from './${ camel ( schema . name ) } '` ) &&
146
- ! stringData . includes ( `export * from "./${ camel ( schema . name ) } "` )
154
+ ! stringData . includes (
155
+ `export * from './${ camel ( schema . name ) } ${ ext } '` ,
156
+ ) &&
157
+ ! stringData . includes (
158
+ `export * from "./${ camel ( schema . name ) } ${ ext } "` ,
159
+ )
147
160
) ;
148
161
} )
149
- . map ( ( schema ) => `export * from './${ camel ( schema . name ) } ';` ) ;
162
+ . map ( ( schema ) => `export * from './${ camel ( schema . name ) } ${ ext } ';` ) ;
150
163
151
164
const currentFileExports = ( stringData
152
165
. match ( / e x p o r t \* f r o m ( .* ) ( ' | " ) / g)
0 commit comments