fix: Fixes broken windows tests (#607)
This commit is contained in:
parent
f60938079a
commit
6e06f8f3c6
|
@ -177,21 +177,23 @@ export class TypegenPrinter {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isNodeModule(rootTypePath)) {
|
if (path.isAbsolute(rootTypePath)) {
|
||||||
|
if (!fs.existsSync(rootTypePath)) {
|
||||||
|
throw new Error(`Root typing path ${rootTypePath} for the type ${typeName} does not exist`)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
try {
|
try {
|
||||||
require.resolve(rootTypePath)
|
require.resolve(rootTypePath)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw new Error(`Module ${rootTypePath} for the type ${typeName} does not exist`)
|
throw new Error(`Module ${rootTypePath} for the type ${typeName} does not exist`)
|
||||||
}
|
}
|
||||||
} else if (!fs.existsSync(rootTypePath)) {
|
|
||||||
throw new Error(`Root typing path ${rootTypePath} for the type ${typeName} does not exist`)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const importPath = isNodeModule(rootTypePath)
|
const importPath = path.isAbsolute(rootTypePath)
|
||||||
? rootTypePath
|
? relativePathTo(rootTypePath, outputPath)
|
||||||
: relativePathTo(rootTypePath, outputPath)
|
|
||||||
.replace(/(\.d)?\.ts/, '')
|
.replace(/(\.d)?\.ts/, '')
|
||||||
.replace(/\\+/g, '/')
|
.replace(/\\+/g, '/')
|
||||||
|
: rootTypePath
|
||||||
|
|
||||||
importMap[importPath] = importMap[importPath] || new Set()
|
importMap[importPath] = importMap[importPath] || new Set()
|
||||||
importMap[importPath].add(rootType.alias ? `${rootType.name} as ${rootType.alias}` : rootType.name)
|
importMap[importPath].add(rootType.alias ? `${rootType.name} as ${rootType.alias}` : rootType.name)
|
||||||
|
|
Loading…
Reference in New Issue