Skip to content

Commit c1b2571

Browse files
devversionandrewseguin
authored andcommitted
fix(ng-update): do not throw if project does not have dependencies (#18470)
The v9 hammerjs migration in some cases tries to remove `hammerjs` from the workspace `package.json`. It always assumes that there is a `dependencies` property. This is not always guaranteed because a project doesn't need to define this property. This change guards against this case and avoids a runtime migration exception. Fixes #18469. (cherry picked from commit 01e4fba)
1 parent 98572bd commit c1b2571

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/material/schematics/ng-update/upgrade-rules/hammer-gestures-v9/hammer-gestures-rule.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -855,9 +855,8 @@ export class HammerGesturesRule extends MigrationRule<null> {
855855

856856
const packageJson = JSON.parse(tree.read('/package.json')!.toString('utf8'));
857857

858-
// We do not handle the case where someone manually added "hammerjs"
859-
// to the dev dependencies.
860-
if (packageJson.dependencies[HAMMER_MODULE_SPECIFIER]) {
858+
// We do not handle the case where someone manually added "hammerjs" to the dev dependencies.
859+
if (packageJson.dependencies && packageJson.dependencies[HAMMER_MODULE_SPECIFIER]) {
861860
delete packageJson.dependencies[HAMMER_MODULE_SPECIFIER];
862861
tree.overwrite('/package.json', JSON.stringify(packageJson, null, 2));
863862
return true;

0 commit comments

Comments
 (0)