0
0
mirror of https://github.com/renovatebot/renovate.git synced 2024-12-22 21:48:32 +00:00
renovatebot_renovate/lib/modules/manager/mint/extract.ts

45 lines
1.2 KiB
TypeScript

import { newlineRegex } from '../../../util/regex';
import { GitTagsDatasource } from '../../datasource/git-tags';
import type { PackageDependency, PackageFileContent } from '../types';
export function extractPackageFile(content: string): PackageFileContent | null {
const deps: PackageDependency[] = [];
for (const line of content.split(newlineRegex).map((s) => s.trim())) {
if (line === '') {
continue;
}
// commented out line
if (line.startsWith('#')) {
continue;
}
// commented out line after package name
if (line.includes('#')) {
const [uncommentLine] = line.split('#');
deps.push(handleDepInMintfile(uncommentLine));
continue;
}
deps.push(handleDepInMintfile(line));
}
return deps.length ? { deps } : null;
}
function handleDepInMintfile(line: string): PackageDependency {
if (!line.includes('@')) {
return {
depName: line,
skipReason: 'unspecified-version',
};
}
const [depName, currentVersion] = line.split('@').map((s) => s.trim());
return {
depName,
currentValue: currentVersion,
datasource: GitTagsDatasource.id,
packageName: `https://github.com/${depName}.git`,
};
}