Skip to content

Commit 58ffc56

Browse files
fix: fix npx --input url error
1 parent 4c43d5e commit 58ffc56

File tree

4 files changed

+18
-5
lines changed

4 files changed

+18
-5
lines changed

.changeset/dirty-foxes-wink.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'openapi-ts-request': patch
3+
---
4+
5+
fix: fix npx --input url error

README-en_US.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,12 @@ npm run openapi
106106
### NPX
107107

108108
```bash
109-
# npm
110109
npx --package=openapi-ts-request -- openapi -i ./openapi.json -o ./apis
110+
npx --package=openapi-ts-request -- openapi -i https://petstore3.swagger.io/api/v3/openapi.json -o ./apis
111111

112112
# pnpm
113-
pnpm --package=openapi-ts-request dlx openapi -i ./openapi.json -o ./apis
113+
pnpm --package=openapi-ts-request@latest dlx openapi -i ./openapi.json -o ./apis
114+
pnpm --package=openapi-ts-request@latest dlx openapi -i https://petstore3.swagger.io/api/v3/openapi.json -o ./apis
114115
```
115116

116117
### CLI

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,11 @@ npm run openapi
108108
```bash
109109
# npm
110110
npx --package=openapi-ts-request -- openapi -i ./openapi.json -o ./apis
111+
npx --package=openapi-ts-request -- openapi -i https://petstore3.swagger.io/api/v3/openapi.json -o ./apis
111112

112113
# pnpm
113-
pnpm --package=openapi-ts-request dlx openapi -i ./openapi.json -o ./apis
114+
pnpm --package=openapi-ts-request@latest dlx openapi -i ./openapi.json -o ./apis
115+
pnpm --package=openapi-ts-request@latest dlx openapi -i https://petstore3.swagger.io/api/v3/openapi.json -o ./apis
114116
```
115117

116118
### CLI

src/bin/openapi.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,13 @@ const params = program
5656
.opts();
5757

5858
function getPath(path: string) {
59-
const cwd = process.cwd();
60-
return join(cwd, path);
59+
const isUrl = path.startsWith('http');
60+
61+
if (isUrl) {
62+
return path;
63+
}
64+
65+
return join(process.cwd(), path);
6166
}
6267

6368
async function run() {

0 commit comments

Comments
 (0)