Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 84367b6

Browse files
alan-agius4clydin
authored andcommittedOct 28, 2020
fix(@schematics/update): update fail when using yarn 2.0 protocols
Closes #19203
1 parent b0ed37a commit 84367b6

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed
 

‎packages/schematics/update/update/index.ts

+3-4
Original file line numberDiff line numberDiff line change
@@ -865,10 +865,9 @@ export default function(options: UpdateSchema): Rule {
865865
try {
866866
return isPkgFromRegistry(name, specifier);
867867
} catch {
868-
// Abort on failure because package.json is malformed.
869-
throw new SchematicsException(
870-
`Failed to parse dependency "${name}" with specifier "${specifier}"`
871-
+ ` from package.json. Is the specifier malformed?`);
868+
logger.warn(`Package ${name} was not found on the registry. Skipping.`);
869+
870+
return false;
872871
}
873872
}));
874873
const packages = _buildPackageList(options, npmDeps, logger);

‎packages/schematics/update/update/index_spec.ts

+18
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,24 @@ describe('@schematics/update', () => {
173173
).toPromise().then(done, done.fail);
174174
}, 45000);
175175

176+
it('should not error with yarn 2.0 protocols', async () => {
177+
const tree = new UnitTestTree(new HostTree(new virtualFs.test.TestHost({
178+
'/package.json': `{
179+
"name": "blah",
180+
"dependencies": {
181+
"src": "src@link:./src",
182+
"@angular-devkit-tests/update-base": "1.0.0"
183+
}
184+
}`,
185+
})));
186+
187+
const newTree = await schematicRunner.runSchematicAsync('update', {
188+
packages: ['@angular-devkit-tests/update-base'],
189+
}, tree).toPromise();
190+
const { dependencies } = JSON.parse(newTree.readContent('/package.json'));
191+
expect(dependencies['@angular-devkit-tests/update-base']).toBe('1.1.0');
192+
});
193+
176194
it('updates Angular as compatible with Angular N-1', done => {
177195
// Add the basic migration package.
178196
const content = virtualFs.fileBufferToString(host.sync.read(normalize('/package.json')));

0 commit comments

Comments
 (0)
Please sign in to comment.