Fix review points and refactor code
This commit is contained in:
parent
48a8ae427d
commit
f32e21fe46
|
@ -25,4 +25,4 @@ jobs:
|
|||
uses: actions/publish-action@v0.2.0
|
||||
with:
|
||||
source-tag: ${{ env.TAG_NAME }}
|
||||
slack-webhook: ${{ secrets.SLACK_WEBHOOK }}
|
||||
slack-webhook: ${{ secrets.SLACK_WEBHOOK }}
|
||||
|
|
|
@ -212,8 +212,7 @@ class DotnetVersionResolver {
|
|||
}
|
||||
resolveVersionInput() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
if (!semver_1.default.valid(this.inputVersion) &&
|
||||
!semver_1.default.validRange(this.inputVersion)) {
|
||||
if (!this.isValidVersion(this.inputVersion)) {
|
||||
throw new Error(`'dotnet-version' was supplied in invalid format: ${this.inputVersion}! Supported syntax: A.B.C, A.B, A.B.x, A, A.x`);
|
||||
}
|
||||
if (semver_1.default.valid(this.inputVersion)) {
|
||||
|
@ -222,9 +221,9 @@ class DotnetVersionResolver {
|
|||
}
|
||||
else {
|
||||
const [major, minor] = this.inputVersion.split('.');
|
||||
if (this.testTag(major)) {
|
||||
if (this.isNumericTag(major)) {
|
||||
this.resolvedArgument.type = 'channel';
|
||||
if (this.testTag(minor)) {
|
||||
if (this.isNumericTag(minor)) {
|
||||
this.resolvedArgument.value = `${major}.${minor}`;
|
||||
}
|
||||
else {
|
||||
|
@ -239,7 +238,10 @@ class DotnetVersionResolver {
|
|||
}
|
||||
});
|
||||
}
|
||||
testTag(versionTag) {
|
||||
isValidVersion(version) {
|
||||
return semver_1.default.valid(version) || semver_1.default.validRange(version) ? true : false;
|
||||
}
|
||||
isNumericTag(versionTag) {
|
||||
return /^\d+$/.test(versionTag);
|
||||
}
|
||||
createDotNetVersion() {
|
||||
|
|
|
@ -42,10 +42,7 @@ export class DotnetVersionResolver {
|
|||
}
|
||||
|
||||
private async resolveVersionInput(): Promise<void> {
|
||||
if (
|
||||
!semver.valid(this.inputVersion) &&
|
||||
!semver.validRange(this.inputVersion)
|
||||
) {
|
||||
if (!this.isValidVersion(this.inputVersion)) {
|
||||
throw new Error(
|
||||
`'dotnet-version' was supplied in invalid format: ${this.inputVersion}! Supported syntax: A.B.C, A.B, A.B.x, A, A.x`
|
||||
);
|
||||
|
@ -56,9 +53,9 @@ export class DotnetVersionResolver {
|
|||
} else {
|
||||
const [major, minor] = this.inputVersion.split('.');
|
||||
|
||||
if (this.testTag(major)) {
|
||||
if (this.isNumericTag(major)) {
|
||||
this.resolvedArgument.type = 'channel';
|
||||
if (this.testTag(minor)) {
|
||||
if (this.isNumericTag(minor)) {
|
||||
this.resolvedArgument.value = `${major}.${minor}`;
|
||||
} else {
|
||||
const httpClient = new hc.HttpClient('actions/setup-dotnet', [], {
|
||||
|
@ -75,7 +72,11 @@ export class DotnetVersionResolver {
|
|||
}
|
||||
}
|
||||
|
||||
private testTag(versionTag): Boolean {
|
||||
private isValidVersion(version) {
|
||||
return semver.valid(version) || semver.validRange(version) ? true : false;
|
||||
}
|
||||
|
||||
private isNumericTag(versionTag): Boolean {
|
||||
return /^\d+$/.test(versionTag);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue