Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: massage depName if missing #28831

Merged
merged 1 commit into from
May 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/workers/repository/extract/manager-files.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ describe('workers/repository/extract/manager-files', () => {
fileMatch.getMatchingFiles.mockReturnValue(['Dockerfile']);
fs.readLocalFile.mockResolvedValueOnce('some content');
html.extractPackageFile = jest.fn(() => ({
deps: [{}, { replaceString: 'abc' }],
deps: [{}, { replaceString: 'abc', packageName: 'p' }],
})) as never;
const res = await getManagerPackageFiles(managerConfig);
expect(res).toEqual([
{
packageFile: 'Dockerfile',
deps: [{}, { replaceString: 'abc' }],
deps: [{}, { replaceString: 'abc', packageName: 'p', depName: 'p' }],
},
]);
});
Expand Down
14 changes: 14 additions & 0 deletions lib/workers/repository/extract/manager-files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,18 @@ import type { PackageFile } from '../../../modules/manager/types';
import { readLocalFile } from '../../../util/fs';
import type { WorkerExtractConfig } from '../../types';

function massageDepNames(packageFiles: PackageFile[] | null): void {
if (packageFiles) {
for (const packageFile of packageFiles) {
for (const dep of packageFile.deps) {
if (dep.packageName && !dep.depName) {
dep.depName = dep.packageName;
}
}
}
}
}

export async function getManagerPackageFiles(
config: WorkerExtractConfig,
): Promise<PackageFile[] | null> {
Expand All @@ -35,6 +47,7 @@ export async function getManagerPackageFiles(
config,
fileList,
);
massageDepNames(allPackageFiles);
return allPackageFiles;
}
const packageFiles: PackageFile[] = [];
Expand All @@ -58,5 +71,6 @@ export async function getManagerPackageFiles(
logger.debug(`${packageFile} has no content`);
}
}
massageDepNames(packageFiles);
return packageFiles;
}