Skip to content

Commit

Permalink
fix(ng-update): do not throw if project does not have dependencies (#…
Browse files Browse the repository at this point in the history
…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.
  • Loading branch information
devversion committed Feb 20, 2020
1 parent aea79f0 commit 01e4fba
Showing 1 changed file with 2 additions and 3 deletions.
Expand Up @@ -853,9 +853,8 @@ export class HammerGesturesRule extends MigrationRule<null> {

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

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

0 comments on commit 01e4fba

Please sign in to comment.