Skip to content

Commit 42231dd

Browse files
alan-agius4clydin
authored andcommitted
fix(@schematics/update): update fail when using yarn 2.0 protocols
Closes #19203
1 parent 0491717 commit 42231dd

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

Diff for: packages/schematics/update/update/index.ts

+3-4
Original file line numberDiff line numberDiff line change
@@ -845,10 +845,9 @@ export default function(options: UpdateSchema): Rule {
845845
try {
846846
return isPkgFromRegistry(name, specifier);
847847
} catch {
848-
// Abort on failure because package.json is malformed.
849-
throw new SchematicsException(
850-
`Failed to parse dependency "${name}" with specifier "${specifier}"`
851-
+ ` from package.json. Is the specifier malformed?`);
848+
logger.warn(`Package ${name} was not found on the registry. Skipping.`);
849+
850+
return false;
852851
}
853852
}));
854853
const packages = _buildPackageList(options, npmDeps, logger);

Diff for: packages/schematics/update/update/index_spec.ts

+18
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,24 @@ describe('@schematics/update', () => {
7272
).toPromise().then(done, done.fail);
7373
}, 45000);
7474

75+
it('should not error with yarn 2.0 protocols', async () => {
76+
const tree = new UnitTestTree(new HostTree(new virtualFs.test.TestHost({
77+
'/package.json': `{
78+
"name": "blah",
79+
"dependencies": {
80+
"src": "src@link:./src",
81+
"@angular-devkit-tests/update-base": "1.0.0"
82+
}
83+
}`,
84+
})));
85+
86+
const newTree = await schematicRunner.runSchematicAsync('update', {
87+
packages: ['@angular-devkit-tests/update-base'],
88+
}, tree).toPromise();
89+
const { dependencies } = JSON.parse(newTree.readContent('/package.json'));
90+
expect(dependencies['@angular-devkit-tests/update-base']).toBe('1.1.0');
91+
});
92+
7593
it('updates Angular as compatible with Angular N-1', done => {
7694
// Add the basic migration package.
7795
const content = virtualFs.fileBufferToString(host.sync.read(normalize('/package.json')));

0 commit comments

Comments
 (0)