mirror of
https://github.com/actions/setup-dotnet.git
synced 2025-08-23 00:50:19 +00:00
Change logic of validation and parsing of version input
This commit is contained in:
parent
fe51dba858
commit
302825fe54
21
dist/index.js
vendored
21
dist/index.js
vendored
@ -211,11 +211,9 @@ class DotnetVersionResolver {
|
|||||||
this.resolvedArgument = { type: '', value: '', qualityFlag: false };
|
this.resolvedArgument = { type: '', value: '', qualityFlag: false };
|
||||||
}
|
}
|
||||||
resolveVersionInput() {
|
resolveVersionInput() {
|
||||||
var _a;
|
if (!semver_1.default.valid(this.inputVersion) &&
|
||||||
const ValidatingRegEx = /^\d+.\d+/i;
|
!semver_1.default.validRange(this.inputVersion)) {
|
||||||
const ReplacingRegEx = /^(\d+.\d+).[x/*]$/i;
|
throw new Error(`'dotnet-version' was supplied in invalid format: ${this.inputVersion}! Supported syntax: A.B.C, A.B.C-D, A.B.x, A.B.X, A.B.*`);
|
||||||
if (!ValidatingRegEx.test(this.inputVersion)) {
|
|
||||||
throw new Error(`'dotnet-version' was supplied in invalid format: ${this.inputVersion}! Supported syntax: A.B.C, A.B.C-D, A.B, A.B.x, A.B.X, A.B.*`);
|
|
||||||
}
|
}
|
||||||
if (semver_1.default.valid(this.inputVersion)) {
|
if (semver_1.default.valid(this.inputVersion)) {
|
||||||
this.resolvedArgument.type = 'version';
|
this.resolvedArgument.type = 'version';
|
||||||
@ -224,8 +222,11 @@ class DotnetVersionResolver {
|
|||||||
else {
|
else {
|
||||||
this.resolvedArgument.type = 'channel';
|
this.resolvedArgument.type = 'channel';
|
||||||
this.resolvedArgument.qualityFlag = true;
|
this.resolvedArgument.qualityFlag = true;
|
||||||
this.resolvedArgument.value = ReplacingRegEx.test(this.inputVersion)
|
this.resolvedArgument.value = semver_1.default.validRange(this.inputVersion)
|
||||||
? (_a = this.inputVersion.match(ReplacingRegEx)) === null || _a === void 0 ? void 0 : _a[1]
|
? this.inputVersion
|
||||||
|
.split('.')
|
||||||
|
.slice(0, 2)
|
||||||
|
.join('.')
|
||||||
: this.inputVersion;
|
: this.inputVersion;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -267,8 +268,7 @@ class DotnetCoreInstaller {
|
|||||||
let escapedScript = path
|
let escapedScript = path
|
||||||
.join(__dirname, '..', 'externals', 'install-dotnet.ps1')
|
.join(__dirname, '..', 'externals', 'install-dotnet.ps1')
|
||||||
.replace(/'/g, "''");
|
.replace(/'/g, "''");
|
||||||
let command = `& '${escapedScript}'`;
|
let command = `& '${escapedScript}' ${versionObject.type} ${versionObject.value}`;
|
||||||
command += ` ${versionObject.type} ${versionObject.value}`;
|
|
||||||
if (this.quality) {
|
if (this.quality) {
|
||||||
if (versionObject.qualityFlag) {
|
if (versionObject.qualityFlag) {
|
||||||
command += ` -Quality ${this.quality}`;
|
command += ` -Quality ${this.quality}`;
|
||||||
@ -312,8 +312,7 @@ class DotnetCoreInstaller {
|
|||||||
.replace(/'/g, "''");
|
.replace(/'/g, "''");
|
||||||
fs_1.chmodSync(escapedScript, '777');
|
fs_1.chmodSync(escapedScript, '777');
|
||||||
const scriptPath = yield io.which(escapedScript, true);
|
const scriptPath = yield io.which(escapedScript, true);
|
||||||
let scriptArguments = [];
|
let scriptArguments = [versionObject.type, versionObject.value];
|
||||||
scriptArguments.push(versionObject.type, versionObject.value);
|
|
||||||
if (this.quality) {
|
if (this.quality) {
|
||||||
if (versionObject.qualityFlag) {
|
if (versionObject.qualityFlag) {
|
||||||
scriptArguments.push('--quality', this.quality);
|
scriptArguments.push('--quality', this.quality);
|
||||||
|
@ -40,11 +40,12 @@ export class DotnetVersionResolver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private resolveVersionInput(): void {
|
private resolveVersionInput(): void {
|
||||||
const ValidatingRegEx = /^\d+.\d+/i;
|
if (
|
||||||
const ReplacingRegEx = /^(\d+.\d+).[x/*]$/i;
|
!semver.valid(this.inputVersion) &&
|
||||||
if (!ValidatingRegEx.test(this.inputVersion)) {
|
!semver.validRange(this.inputVersion)
|
||||||
|
) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`'dotnet-version' was supplied in invalid format: ${this.inputVersion}! Supported syntax: A.B.C, A.B.C-D, A.B, A.B.x, A.B.X, A.B.*`
|
`'dotnet-version' was supplied in invalid format: ${this.inputVersion}! Supported syntax: A.B.C, A.B.C-D, A.B.x, A.B.X, A.B.*`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (semver.valid(this.inputVersion)) {
|
if (semver.valid(this.inputVersion)) {
|
||||||
@ -53,8 +54,11 @@ export class DotnetVersionResolver {
|
|||||||
} else {
|
} else {
|
||||||
this.resolvedArgument.type = 'channel';
|
this.resolvedArgument.type = 'channel';
|
||||||
this.resolvedArgument.qualityFlag = true;
|
this.resolvedArgument.qualityFlag = true;
|
||||||
this.resolvedArgument.value = ReplacingRegEx.test(this.inputVersion)
|
this.resolvedArgument.value = semver.validRange(this.inputVersion)
|
||||||
? this.inputVersion.match(ReplacingRegEx)?.[1]!
|
? this.inputVersion
|
||||||
|
.split('.')
|
||||||
|
.slice(0, 2)
|
||||||
|
.join('.')
|
||||||
: this.inputVersion;
|
: this.inputVersion;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -105,9 +109,7 @@ export class DotnetCoreInstaller {
|
|||||||
let escapedScript = path
|
let escapedScript = path
|
||||||
.join(__dirname, '..', 'externals', 'install-dotnet.ps1')
|
.join(__dirname, '..', 'externals', 'install-dotnet.ps1')
|
||||||
.replace(/'/g, "''");
|
.replace(/'/g, "''");
|
||||||
let command = `& '${escapedScript}'`;
|
let command = `& '${escapedScript}' ${versionObject.type} ${versionObject.value}`;
|
||||||
|
|
||||||
command += ` ${versionObject.type} ${versionObject.value}`;
|
|
||||||
|
|
||||||
if (this.quality) {
|
if (this.quality) {
|
||||||
if (versionObject.qualityFlag) {
|
if (versionObject.qualityFlag) {
|
||||||
@ -163,9 +165,7 @@ export class DotnetCoreInstaller {
|
|||||||
|
|
||||||
const scriptPath = await io.which(escapedScript, true);
|
const scriptPath = await io.which(escapedScript, true);
|
||||||
|
|
||||||
let scriptArguments: string[] = [];
|
let scriptArguments: string[] = [versionObject.type, versionObject.value];
|
||||||
|
|
||||||
scriptArguments.push(versionObject.type, versionObject.value);
|
|
||||||
|
|
||||||
if (this.quality) {
|
if (this.quality) {
|
||||||
if (versionObject.qualityFlag) {
|
if (versionObject.qualityFlag) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user