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) => { elevateFileReplacePositionField(extractedDeps).forEach((dep) => {
const key = dep.managerData.packageFile; const key = dep.managerData?.packageFile;
const pkgFile: PackageFile = packageFilesByName[key]; // istanbul ignore else
const { deps } = pkgFile; if (key) {
deps.push({ const pkgFile: PackageFile = packageFilesByName[key];
...dep, const { deps } = pkgFile;
registryUrls: [ deps.push({
...new Set([ ...dep,
...defaultRegistryUrls, registryUrls: [
...(dep.registryUrls || []), ...new Set([
...registryUrls, ...defaultRegistryUrls,
]), ...(dep.registryUrls || []),
], ...registryUrls,
}); ]),
packageFilesByName[key] = pkgFile; ],
});
packageFilesByName[key] = pkgFile;
} else {
logger.warn({ dep }, `Failed to process Gradle dependency`);
}
}); });
return Object.values(packageFilesByName); return Object.values(packageFilesByName);