File tree 1 file changed +4
-2
lines changed
packages/openapi-typescript/bin
1 file changed +4
-2
lines changed Original file line number Diff line number Diff line change @@ -174,6 +174,8 @@ async function main() {
174
174
// handle local schema(s)
175
175
const inputSpecPaths = await glob ( pathToSpec ) ;
176
176
const isGlob = inputSpecPaths . length > 1 ;
177
+ const isDirUrl = outputDir . pathname === outputFile . pathname ;
178
+ const isFile = fs . existsSync ( outputDir ) && fs . lstatSync ( outputDir ) . isFile ( ) ;
177
179
178
180
// error: no matches for glob
179
181
if ( inputSpecPaths . length === 0 ) {
@@ -182,7 +184,7 @@ async function main() {
182
184
}
183
185
184
186
// error: tried to glob output to single file
185
- if ( isGlob && output === OUTPUT_FILE && ( ( fs . existsSync ( outputDir ) && fs . lstatSync ( outputDir ) . isFile ( ) ) || outputDir . pathname !== outputFile . pathname ) ) {
187
+ if ( isGlob && output === OUTPUT_FILE && ( isFile || ! isDirUrl ) ) {
186
188
error ( `Expected directory for --output if using glob patterns. Received "${ flags . output } ".` ) ;
187
189
process . exit ( 1 ) ;
188
190
}
@@ -191,7 +193,7 @@ async function main() {
191
193
await Promise . all (
192
194
inputSpecPaths . map ( async ( specPath ) => {
193
195
if ( flags . output !== "." && output === OUTPUT_FILE ) {
194
- if ( isGlob || outputDir . pathname === outputFile . pathname ) {
196
+ if ( isGlob || isDirUrl ) {
195
197
fs . mkdirSync ( new URL ( path . dirname ( specPath ) , outputDir ) , { recursive : true } ) ; // recursively make parent dirs
196
198
} else {
197
199
fs . mkdirSync ( outputDir , { recursive : true } ) ; // recursively make parent dirs
You can’t perform that action at this time.
0 commit comments