0
0
Fork 0
mirror of https://github.com/renovatebot/renovate.git synced 2025-01-27 05:09:37 +00:00
renovatebot_renovate/lib/workers/repository/extract/supersedes.ts
2023-11-07 15:50:29 +00:00

36 lines
1.2 KiB
TypeScript

import is from '@sindresorhus/is';
import { get } from '../../../modules/manager';
import type { ExtractResults } from './types';
export function processSupersedesManagers(
extractResults: ExtractResults[],
): void {
for (const { manager, packageFiles } of extractResults) {
if (!packageFiles) {
continue;
}
const supersedesManagers = get(manager, 'supersedesManagers');
if (is.nonEmptyArray(supersedesManagers)) {
const supercedingPackageFileNames = packageFiles.map(
(packageFile) => packageFile.packageFile,
);
for (const supercededManager of supersedesManagers) {
const supercededManagerResults = extractResults.find(
(result) => result.manager === supercededManager,
);
if (supercededManagerResults?.packageFiles) {
supercededManagerResults.packageFiles =
supercededManagerResults.packageFiles.filter((packageFile) => {
if (
!packageFile.lockFiles?.length &&
supercedingPackageFileNames.includes(packageFile.packageFile)
) {
return false;
}
return true;
});
}
}
}
}
}