work on fixing test

This commit is contained in:
Dmitry Shibanov 2021-03-17 14:56:08 +03:00
parent 36fa9877a9
commit 20afff9c90
3 changed files with 6 additions and 18 deletions

View File

@ -42,7 +42,6 @@ describe('version tests', () => {
'.2.3', '.2.3',
'.2.x', '.2.x',
'1', '1',
'2.x',
'*.*.1', '*.*.1',
'*.1', '*.1',
'*.', '*.',

12
dist/index.js vendored
View File

@ -16869,20 +16869,14 @@ class DotNetVersionInfo {
return; return;
} }
//Note: No support for previews when using generic //Note: No support for previews when using generic
let parts = version.split('.'); const parts = version.split('.');
if (parts.length < 2 || parts.length > 3) if (parts.length < 2 || parts.length > 3)
this.throwInvalidVersionFormat(); this.throwInvalidVersionFormat();
if (parts.length == 3 && parts[2] !== 'x' && parts[2] !== '*') { if (parts.length == 3 && parts[2] !== 'x' && parts[2] !== '*') {
this.throwInvalidVersionFormat(); this.throwInvalidVersionFormat();
} }
let major = this.getVersionNumberOrThrow(parts[0]); const major = this.getVersionNumberOrThrow(parts[0]);
let minor; const minor = ['x', '*'].includes(parts[1]) ? parts[1] : this.getVersionNumberOrThrow(parts[1]);
if (parts[1] === 'x') {
minor = parts[1];
}
else {
minor = this.getVersionNumberOrThrow(parts[1]);
}
this.fullversion = major + '.' + minor; this.fullversion = major + '.' + minor;
} }
getVersionNumberOrThrow(input) { getVersionNumberOrThrow(input) {

View File

@ -30,7 +30,7 @@ export class DotNetVersionInfo {
} }
//Note: No support for previews when using generic //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(); if (parts.length < 2 || parts.length > 3) this.throwInvalidVersionFormat();
@ -38,13 +38,8 @@ export class DotNetVersionInfo {
this.throwInvalidVersionFormat(); this.throwInvalidVersionFormat();
} }
let major = this.getVersionNumberOrThrow(parts[0]); const major = this.getVersionNumberOrThrow(parts[0]);
let minor; const minor = ['x', '*'].includes(parts[1]) ? parts[1] : this.getVersionNumberOrThrow(parts[1]);
if (parts[1] === 'x') {
minor = parts[1];
} else {
minor = this.getVersionNumberOrThrow(parts[1]);
}
this.fullversion = major + '.' + minor; this.fullversion = major + '.' + minor;
} }