fix(gradle): Avoid crash for missing managerData (#11727)

This commit is contained in:
Sergei Zharinov 2021-09-14 13:13:51 +03:00 committed by GitHub
parent 45d1aeecc3
commit 522d23e2c5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -98,20 +98,25 @@ export async function extractAllPackageFiles(
}
elevateFileReplacePositionField(extractedDeps).forEach((dep) => {
const key = dep.managerData.packageFile;
const pkgFile: PackageFile = packageFilesByName[key];
const { deps } = pkgFile;
deps.push({
...dep,
registryUrls: [
...new Set([
...defaultRegistryUrls,
...(dep.registryUrls || []),
...registryUrls,
]),
],
});
packageFilesByName[key] = pkgFile;
const key = dep.managerData?.packageFile;
// istanbul ignore else
if (key) {
const pkgFile: PackageFile = packageFilesByName[key];
const { deps } = pkgFile;
deps.push({
...dep,
registryUrls: [
...new Set([
...defaultRegistryUrls,
...(dep.registryUrls || []),
...registryUrls,
]),
],
});
packageFilesByName[key] = pkgFile;
} else {
logger.warn({ dep }, `Failed to process Gradle dependency`);
}
});
return Object.values(packageFilesByName);