mirror of
https://github.com/actions/setup-python
synced 2025-04-05 23:09:44 +00:00
Add range validation for toml files (#726)
This commit is contained in:
16
src/utils.ts
16
src/utils.ts
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user