Skip to content

Commit b05a3f2

Browse files
author
IvanZosimov
committed
Fix review points, rebuild solution
1 parent 38b49fb commit b05a3f2

File tree

4 files changed

+13
-25
lines changed

4 files changed

+13
-25
lines changed

__tests__/setup-dotnet.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ describe('setup-dotnet tests', () => {
5959

6060
const expectedDebugMessage =
6161
'No version found, trying to find version from global.json';
62-
const expectedInfoMessage = `A global.json wasn't found in the root directory. No .NET version will be installed.`;
62+
const expectedInfoMessage = `The global.json wasn't found in the root directory. No .NET version will be installed.`;
6363

6464
await setup.run();
6565

dist/index.js

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -242,11 +242,8 @@ const path_1 = __importDefault(__nccwpck_require__(1017));
242242
const os_1 = __importDefault(__nccwpck_require__(2037));
243243
const semver_1 = __importDefault(__nccwpck_require__(5911));
244244
const utils_1 = __nccwpck_require__(918);
245-
var DotnetInstallerLimits;
246-
(function (DotnetInstallerLimits) {
247-
DotnetInstallerLimits[DotnetInstallerLimits["QualityInputMinimalMajorTag"] = 6] = "QualityInputMinimalMajorTag";
248-
DotnetInstallerLimits[DotnetInstallerLimits["LatestPatchSyntaxMinimalMajorTag"] = 5] = "LatestPatchSyntaxMinimalMajorTag";
249-
})(DotnetInstallerLimits || (DotnetInstallerLimits = {}));
245+
const QUALITY_INPUT_MINIMAL_MAJOR_TAG = 6;
246+
const LATEST_PATCH_SYNTAX_MINIMAL_MAJOR_TAG = 5;
250247
class DotnetVersionResolver {
251248
constructor(version) {
252249
this.inputVersion = version.trim();
@@ -272,8 +269,7 @@ class DotnetVersionResolver {
272269
var _b, _c;
273270
const majorTag = (_c = (_b = this.inputVersion.match(/^(?<majorTag>\d+)\.\d+\.\d{1}x{2}$/)) === null || _b === void 0 ? void 0 : _b.groups) === null || _c === void 0 ? void 0 : _c.majorTag;
274271
if (majorTag &&
275-
parseInt(majorTag) <
276-
DotnetInstallerLimits.LatestPatchSyntaxMinimalMajorTag) {
272+
parseInt(majorTag) < LATEST_PATCH_SYNTAX_MINIMAL_MAJOR_TAG) {
277273
throw new Error(`The 'dotnet-version' was supplied in invalid format: ${this.inputVersion}! The A.B.Cxx syntax is available since the .NET 5.0 release.`);
278274
}
279275
return majorTag ? true : false;
@@ -300,9 +296,7 @@ class DotnetVersionResolver {
300296
this.resolvedArgument.value = 'LTS';
301297
}
302298
this.resolvedArgument.qualityFlag =
303-
parseInt(major) >= DotnetInstallerLimits.QualityInputMinimalMajorTag
304-
? true
305-
: false;
299+
parseInt(major) >= QUALITY_INPUT_MINIMAL_MAJOR_TAG ? true : false;
306300
});
307301
}
308302
createDotNetVersion() {
@@ -556,7 +550,7 @@ function run() {
556550
versions.push(getVersionFromGlobalJson(globalJsonPath));
557551
}
558552
else {
559-
core.info(`A global.json wasn't found in the root directory. No .NET version will be installed.`);
553+
core.info(`The global.json wasn't found in the root directory. No .NET version will be installed.`);
560554
}
561555
}
562556
if (versions.length) {
@@ -613,7 +607,7 @@ function outputInstalledVersion(installedVersions, globalJsonFileInput) {
613607
return;
614608
}
615609
if (globalJsonFileInput) {
616-
const versionToOutput = installedVersions.at(-1);
610+
const versionToOutput = installedVersions.at(-1); // .NET SDK version parsed from the global.json file is installed last
617611
core.setOutput('dotnet-version', versionToOutput);
618612
return;
619613
}

src/installer.ts

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,8 @@ export interface DotnetVersion {
1616
qualityFlag: boolean;
1717
}
1818

19-
enum DotnetInstallerLimits {
20-
QualityInputMinimalMajorTag = 6,
21-
LatestPatchSyntaxMinimalMajorTag = 5
22-
}
23-
19+
const QUALITY_INPUT_MINIMAL_MAJOR_TAG = 6;
20+
const LATEST_PATCH_SYNTAX_MINIMAL_MAJOR_TAG = 5;
2421
export class DotnetVersionResolver {
2522
private inputVersion: string;
2623
private resolvedArgument: DotnetVersion;
@@ -53,8 +50,7 @@ export class DotnetVersionResolver {
5350
)?.groups?.majorTag;
5451
if (
5552
majorTag &&
56-
parseInt(majorTag) <
57-
DotnetInstallerLimits.LatestPatchSyntaxMinimalMajorTag
53+
parseInt(majorTag) < LATEST_PATCH_SYNTAX_MINIMAL_MAJOR_TAG
5854
) {
5955
throw new Error(
6056
`The 'dotnet-version' was supplied in invalid format: ${this.inputVersion}! The A.B.Cxx syntax is available since the .NET 5.0 release.`
@@ -82,9 +78,7 @@ export class DotnetVersionResolver {
8278
this.resolvedArgument.value = 'LTS';
8379
}
8480
this.resolvedArgument.qualityFlag =
85-
parseInt(major) >= DotnetInstallerLimits.QualityInputMinimalMajorTag
86-
? true
87-
: false;
81+
parseInt(major) >= QUALITY_INPUT_MINIMAL_MAJOR_TAG ? true : false;
8882
}
8983

9084
public async createDotNetVersion(): Promise<DotnetVersion> {

src/setup-dotnet.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export async function run() {
4848
versions.push(getVersionFromGlobalJson(globalJsonPath));
4949
} else {
5050
core.info(
51-
`A global.json wasn't found in the root directory. No .NET version will be installed.`
51+
`The global.json wasn't found in the root directory. No .NET version will be installed.`
5252
);
5353
}
5454
}
@@ -121,7 +121,7 @@ function outputInstalledVersion(
121121
}
122122

123123
if (globalJsonFileInput) {
124-
const versionToOutput = installedVersions.at(-1);
124+
const versionToOutput = installedVersions.at(-1); // .NET SDK version parsed from the global.json file is installed last
125125
core.setOutput('dotnet-version', versionToOutput);
126126
return;
127127
}

0 commit comments

Comments
 (0)