Skip to content

Commit

Permalink
fix(@schematics/update): stabilize package list before continuing
Browse files Browse the repository at this point in the history
Fix #10875
  • Loading branch information
filipesilva authored and hansl committed Jun 6, 2018
1 parent d1dd576 commit 07a6116
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
14 changes: 10 additions & 4 deletions packages/schematics/update/update/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -790,10 +790,16 @@ export default function(options: UpdateSchema): Rule {

map(npmPackageJsonMap => {
// Augment the command line package list with packageGroups and forward peer dependencies.
npmPackageJsonMap.forEach((npmPackageJson) => {
_addPackageGroup(packages, allDependencies, npmPackageJson, logger);
_addPeerDependencies(packages, allDependencies, npmPackageJson, logger);
});
// Each added package may uncover new package groups and peer dependencies, so we must
// repeat this process until the package list stabilizes.
let lastPackagesSize;
do {
lastPackagesSize = packages.size;
npmPackageJsonMap.forEach((npmPackageJson) => {
_addPackageGroup(packages, allDependencies, npmPackageJson, logger);
_addPeerDependencies(packages, allDependencies, npmPackageJson, logger);
});
} while (packages.size > lastPackagesSize);

// Build the PackageInfo for each module.
const packageInfoMap = new Map<string, PackageInfo>();
Expand Down
5 changes: 5 additions & 0 deletions packages/schematics/update/update/index_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,11 @@ describe('@schematics/update', () => {
dependencies['@angular/animations'] = '5.1.0';
dependencies['@angular/common'] = '5.1.0';
dependencies['@angular/compiler'] = '5.1.0';
dependencies['@angular/compiler-cli'] = '5.1.0';
dependencies['@angular/platform-browser'] = '5.1.0';
dependencies['rxjs'] = '5.5.0';
dependencies['zone.js'] = '0.8.26';
dependencies['typescript'] = '2.4.2';
host.sync.write(
normalize('/package.json'),
virtualFs.stringToFileBuffer(JSON.stringify(packageJson)),
Expand All @@ -176,6 +178,9 @@ describe('@schematics/update', () => {
map(tree => {
const packageJson = JSON.parse(tree.readContent('/package.json'));
expect(packageJson['dependencies']['@angular/core'][0]).toBe('6');
expect(packageJson['dependencies']['rxjs'][0]).toBe('6');
expect(packageJson['dependencies']['typescript'][0]).toBe('2');
expect(packageJson['dependencies']['typescript'][2]).toBe('7');

// Check install task.
expect(schematicRunner.tasks).toEqual([
Expand Down

0 comments on commit 07a6116

Please sign in to comment.