From 20afff9c90f1ba52c7fc7198759eba900832b4cf Mon Sep 17 00:00:00 2001 From: Dmitry Shibanov Date: Wed, 17 Mar 2021 14:56:08 +0300 Subject: [PATCH] work on fixing test --- __tests__/versionutil.test.ts | 1 - dist/index.js | 12 +++--------- src/installer.ts | 11 +++-------- 3 files changed, 6 insertions(+), 18 deletions(-) diff --git a/__tests__/versionutil.test.ts b/__tests__/versionutil.test.ts index a238688..b816013 100644 --- a/__tests__/versionutil.test.ts +++ b/__tests__/versionutil.test.ts @@ -42,7 +42,6 @@ describe('version tests', () => { '.2.3', '.2.x', '1', - '2.x', '*.*.1', '*.1', '*.', diff --git a/dist/index.js b/dist/index.js index aadf381..9febcc2 100644 --- a/dist/index.js +++ b/dist/index.js @@ -16869,20 +16869,14 @@ class DotNetVersionInfo { return; } //Note: No support for previews when using generic - let parts = version.split('.'); + const parts = version.split('.'); if (parts.length < 2 || parts.length > 3) this.throwInvalidVersionFormat(); if (parts.length == 3 && parts[2] !== 'x' && parts[2] !== '*') { this.throwInvalidVersionFormat(); } - let major = this.getVersionNumberOrThrow(parts[0]); - let minor; - if (parts[1] === 'x') { - minor = parts[1]; - } - else { - minor = this.getVersionNumberOrThrow(parts[1]); - } + const major = this.getVersionNumberOrThrow(parts[0]); + const minor = ['x', '*'].includes(parts[1]) ? parts[1] : this.getVersionNumberOrThrow(parts[1]); this.fullversion = major + '.' + minor; } getVersionNumberOrThrow(input) { diff --git a/src/installer.ts b/src/installer.ts index 12113e6..0f3fc42 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -30,7 +30,7 @@ export class DotNetVersionInfo { } //Note: No support for previews when using generic - let parts: string[] = version.split('.'); + const parts: string[] = version.split('.'); if (parts.length < 2 || parts.length > 3) this.throwInvalidVersionFormat(); @@ -38,13 +38,8 @@ export class DotNetVersionInfo { this.throwInvalidVersionFormat(); } - let major = this.getVersionNumberOrThrow(parts[0]); - let minor; - if (parts[1] === 'x') { - minor = parts[1]; - } else { - minor = this.getVersionNumberOrThrow(parts[1]); - } + const major = this.getVersionNumberOrThrow(parts[0]); + const minor = ['x', '*'].includes(parts[1]) ? parts[1] : this.getVersionNumberOrThrow(parts[1]); this.fullversion = major + '.' + minor; }