Skip to content

Commit 44199d4

Browse files
fix: properly resolve paths in openapiTS code caching on Windows
1 parent 8edce55 commit 44199d4

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/module.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import type { FetchOptions } from 'ofetch'
33
import type { OpenAPI3, OpenAPITSOptions } from 'openapi-typescript'
44
import { existsSync } from 'node:fs'
55
import { mkdir, readdir, readFile, unlink, writeFile } from 'node:fs/promises'
6+
import { fileURLToPath } from 'node:url'
67
import {
78
addImportsSources,
89
addPlugin,
@@ -349,7 +350,7 @@ export async function addCachedSchemaTemplate({
349350
await mkdir(cacheDir, { recursive: true })
350351

351352
let fileBody = ''
352-
const filePath = schema instanceof URL ? schema.pathname : schema
353+
const filePath = schema instanceof URL ? fileURLToPath(schema) : schema
353354
if (typeof filePath === 'string' && existsSync(filePath)) {
354355
fileBody = await readFile(filePath, 'utf-8')
355356
}

0 commit comments

Comments
 (0)