Skip to content

Commit 5f20b22

Browse files
committed
Fix file path
1 parent 76a0637 commit 5f20b22

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
@@ -108,8 +108,12 @@ async function generateSchema(pathToSpec) {
108108
let outputFilePath = new URL(flags.output, CWD); // note: may be directory
109109
const isDir = fs.existsSync(outputFilePath) && fs.lstatSync(outputFilePath).isDirectory();
110110
if (isDir) {
111-
const filename = pathToSpec.replace(EXT_RE, ".ts").replace(/^https?:\/\//, '');
112-
outputFilePath = new URL(filename, outputFilePath);
111+
const filename = pathToSpec.replace(EXT_RE, ".ts");
112+
const originalOutputFilePath = outputFilePath;
113+
outputFilePath = new URL(filename, originalOutputFilePath);
114+
if (outputFilePath.protocol !== 'file') {
115+
outputFilePath = new URL(outputFilePath.host.replace(EXT_RE, ".ts"), originalOutputFilePath);
116+
}
113117
}
114118

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

0 commit comments

Comments
 (0)