Skip to content

Commit 6e06f8f

Browse files
authored
fix: Fixes broken windows tests (#607)
1 parent f609380 commit 6e06f8f

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/typegenPrinter.ts

+8-6
Original file line numberDiff line numberDiff line change
@@ -177,21 +177,23 @@ export class TypegenPrinter {
177177
)
178178
}
179179

180-
if (isNodeModule(rootTypePath)) {
180+
if (path.isAbsolute(rootTypePath)) {
181+
if (!fs.existsSync(rootTypePath)) {
182+
throw new Error(`Root typing path ${rootTypePath} for the type ${typeName} does not exist`)
183+
}
184+
} else {
181185
try {
182186
require.resolve(rootTypePath)
183187
} catch (e) {
184188
throw new Error(`Module ${rootTypePath} for the type ${typeName} does not exist`)
185189
}
186-
} else if (!fs.existsSync(rootTypePath)) {
187-
throw new Error(`Root typing path ${rootTypePath} for the type ${typeName} does not exist`)
188190
}
189191

190-
const importPath = isNodeModule(rootTypePath)
191-
? rootTypePath
192-
: relativePathTo(rootTypePath, outputPath)
192+
const importPath = path.isAbsolute(rootTypePath)
193+
? relativePathTo(rootTypePath, outputPath)
193194
.replace(/(\.d)?\.ts/, '')
194195
.replace(/\\+/g, '/')
196+
: rootTypePath
195197

196198
importMap[importPath] = importMap[importPath] || new Set()
197199
importMap[importPath].add(rootType.alias ? `${rootType.name} as ${rootType.alias}` : rootType.name)

0 commit comments

Comments
 (0)