mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-15 09:06:25 +00:00
7e2e0b3f18
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
25 lines
751 B
TypeScript
25 lines
751 B
TypeScript
import { parse } from '@iarna/toml';
|
|
import { logger } from '../../../logger';
|
|
import type { PoetryLock } from './types';
|
|
|
|
export function extractLockFileEntries(
|
|
lockFileContent: string
|
|
): Record<string, string> {
|
|
let poetryLockfile: PoetryLock = {};
|
|
try {
|
|
poetryLockfile = parse(lockFileContent);
|
|
} catch (err) {
|
|
logger.debug({ err }, 'Error parsing poetry.lock file');
|
|
}
|
|
|
|
const lockfileMapping: Record<string, string> = {};
|
|
if (poetryLockfile?.package) {
|
|
// Create a package->version mapping
|
|
for (const poetryPackage of poetryLockfile.package) {
|
|
if (poetryPackage.name && poetryPackage.version) {
|
|
lockfileMapping[poetryPackage.name] = poetryPackage.version;
|
|
}
|
|
}
|
|
}
|
|
return lockfileMapping;
|
|
}
|