Update dotnet utils, to handle more cases

This commit is contained in:
Nikolai Laevskii 2023-09-04 05:13:00 +02:00
parent 507e136364
commit 7b20bfa88d
2 changed files with 24 additions and 2 deletions

10
dist/setup/index.js vendored
View File

@ -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;
};

View File

@ -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;