Skip to content

Commit 19bc66a

Browse files
committed
Fix file path
1 parent 550fcae commit 19bc66a

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

bin/cli.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,12 @@ async function generateSchema(pathToSpec) {
107107
let outputFilePath = new URL(flags.output, CWD); // note: may be directory
108108
const isDir = fs.existsSync(outputFilePath) && fs.lstatSync(outputFilePath).isDirectory();
109109
if (isDir) {
110-
const filename = pathToSpec.replace(EXT_RE, ".ts").replace(/^https?:\/\//, '');
111-
outputFilePath = new URL(filename, outputFilePath);
110+
const filename = pathToSpec.replace(EXT_RE, ".ts");
111+
const originalOutputFilePath = outputFilePath;
112+
outputFilePath = new URL(filename, originalOutputFilePath);
113+
if (outputFilePath.protocol !== 'file') {
114+
outputFilePath = new URL(outputFilePath.host.replace(EXT_RE, ".ts"), originalOutputFilePath);
115+
}
112116
}
113117

114118
fs.writeFileSync(outputFilePath, result, "utf8");

0 commit comments

Comments
 (0)