Skip to content

Commit

Permalink
fix(@schematics/update): update fail when using yarn 2.0 protocols
Browse files Browse the repository at this point in the history
Closes #19203
  • Loading branch information
alan-agius4 authored and clydin committed Oct 28, 2020
1 parent b0ed37a commit 84367b6
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
7 changes: 3 additions & 4 deletions packages/schematics/update/update/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -865,10 +865,9 @@ export default function(options: UpdateSchema): Rule {
try {
return isPkgFromRegistry(name, specifier);
} catch {
// Abort on failure because package.json is malformed.
throw new SchematicsException(
`Failed to parse dependency "${name}" with specifier "${specifier}"`
+ ` from package.json. Is the specifier malformed?`);
logger.warn(`Package ${name} was not found on the registry. Skipping.`);

return false;
}
}));
const packages = _buildPackageList(options, npmDeps, logger);
Expand Down
18 changes: 18 additions & 0 deletions packages/schematics/update/update/index_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,24 @@ describe('@schematics/update', () => {
).toPromise().then(done, done.fail);
}, 45000);

it('should not error with yarn 2.0 protocols', async () => {
const tree = new UnitTestTree(new HostTree(new virtualFs.test.TestHost({
'/package.json': `{
"name": "blah",
"dependencies": {
"src": "src@link:./src",
"@angular-devkit-tests/update-base": "1.0.0"
}
}`,
})));

const newTree = await schematicRunner.runSchematicAsync('update', {
packages: ['@angular-devkit-tests/update-base'],
}, tree).toPromise();
const { dependencies } = JSON.parse(newTree.readContent('/package.json'));
expect(dependencies['@angular-devkit-tests/update-base']).toBe('1.1.0');
});

it('updates Angular as compatible with Angular N-1', done => {
// Add the basic migration package.
const content = virtualFs.fileBufferToString(host.sync.read(normalize('/package.json')));
Expand Down

0 comments on commit 84367b6

Please sign in to comment.