Add range validation for toml files (#726)

This commit is contained in:
Dmitry Shibanov
2023-09-07 15:45:09 +02:00
committed by GitHub
parent f97b83114c
commit 65d7f2d534
4 changed files with 29 additions and 6 deletions

View File

@ -229,7 +229,21 @@ export function getVersionInputFromTomlFile(versionFile: string): string[] {
}
core.info(`Extracted ${versions} from ${versionFile}`);
return Array.from(versions, version => version.split(',').join(' '));
const rawVersions = Array.from(versions, version =>
version.split(',').join(' ')
);
const validatedVersions = rawVersions
.map(item => semver.validRange(item, true))
.filter((versionRange, index) => {
if (!versionRange) {
core.debug(
`The version ${rawVersions[index]} is not valid SemVer range`
);
}
return !!versionRange;
}) as string[];
return validatedVersions;
}
/**