feat(core): add user-friendly error on invalid input

Prevent cryptic error of `TypeError: Cannot read property 'map' of undefined`, which doesn't guide the user towards success
This commit is contained in:
Christopher Dieringer 2020-08-13 08:26:49 -07:00 committed by Victor Savkin
parent d1f740e264
commit adc34f82e3

View File

@ -88,7 +88,14 @@ export function updateImports(schema: Schema) {
const path = tsConfig.compilerOptions.paths[
projectRef.from
] as string[];
if (!path) {
throw new Error(
[
`unable to find "${projectRef.from}" in`,
`${tsConfigPath} compilerOptions.paths`,
].join(' ')
);
}
const updatedPath = path.map((x) =>
x.replace(new RegExp(projectRoot.from, 'g'), projectRoot.to)
);