0
0
mirror of https://github.com/renovatebot/renovate.git synced 2024-12-22 13:38:32 +00:00
renovatebot_renovate/lib/modules/manager/composer/extract.ts
2023-11-07 15:50:29 +00:00

19 lines
505 B
TypeScript

import { logger } from '../../../logger';
import type { PackageFileContent } from '../types';
import { ComposerExtract } from './schema';
export async function extractPackageFile(
content: string,
packageFile: string,
): Promise<PackageFileContent | null> {
const res = await ComposerExtract.safeParseAsync({
content,
fileName: packageFile,
});
if (!res.success) {
logger.debug({ packageFile, err: res.error }, 'Composer: extract failed');
return null;
}
return res.data;
}