Skip to content

Commit

Permalink
feat(core): add user-friendly error on invalid input
Browse files Browse the repository at this point in the history
Prevent cryptic error of `TypeError: Cannot read property 'map' of undefined`, which doesn't guide the user towards success
  • Loading branch information
cdaringe authored and vsavkin committed Sep 24, 2020
1 parent d1f740e commit adc34f8
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion packages/workspace/src/schematics/move/lib/update-imports.ts
Expand Up @@ -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)
);
Expand Down

0 comments on commit adc34f8

Please sign in to comment.