mirror of
https://github.com/actions/setup-dotnet.git
synced 2024-11-25 12:53:06 +07:00
Update dotnet utils, to handle more cases
This commit is contained in:
parent
507e136364
commit
7b20bfa88d
10
dist/setup/index.js
vendored
10
dist/setup/index.js
vendored
@ -72811,7 +72811,15 @@ exports.listSdks = listSdks;
|
||||
* correct version number like '3.1.201', '3.1.201', '3.1.201', '3.1.201', '6.0.402'
|
||||
*/
|
||||
const matchVersionToList = (version, versions) => {
|
||||
const versionRegex = new RegExp(`^${version.replace(/x/g, '\\d+')}`);
|
||||
if (!version || version === 'x' || version === '*') {
|
||||
return versions.at(0);
|
||||
}
|
||||
const versionArray = version.split('.');
|
||||
if (versionArray.length < 3) {
|
||||
versionArray.push(...Array(3 - versionArray.length).fill('x'));
|
||||
}
|
||||
const normalizedVersion = versionArray.join('.');
|
||||
const versionRegex = new RegExp(`^${normalizedVersion.replace(/x/g, '\\d+')}`);
|
||||
const matchedVersion = versions.find(v => versionRegex.test(v));
|
||||
return matchedVersion;
|
||||
};
|
||||
|
@ -28,7 +28,21 @@ export const listSdks = async () => {
|
||||
* correct version number like '3.1.201', '3.1.201', '3.1.201', '3.1.201', '6.0.402'
|
||||
*/
|
||||
export const matchVersionToList = (version: string, versions: string[]) => {
|
||||
const versionRegex = new RegExp(`^${version.replace(/x/g, '\\d+')}`);
|
||||
if (!version || version === 'x' || version === '*') {
|
||||
return versions.at(0);
|
||||
}
|
||||
|
||||
const versionArray = version.split('.');
|
||||
|
||||
if (versionArray.length < 3) {
|
||||
versionArray.push(...Array(3 - versionArray.length).fill('x'));
|
||||
}
|
||||
|
||||
const normalizedVersion = versionArray.join('.');
|
||||
|
||||
const versionRegex = new RegExp(
|
||||
`^${normalizedVersion.replace(/x/g, '\\d+')}`
|
||||
);
|
||||
const matchedVersion = versions.find(v => versionRegex.test(v));
|
||||
|
||||
return matchedVersion;
|
||||
|
Loading…
Reference in New Issue
Block a user