Skip to content

Commit a6dcfb9

Browse files
committed
chore: fix comments aab
1 parent a29ced3 commit a6dcfb9

File tree

3 files changed

+24
-8
lines changed

3 files changed

+24
-8
lines changed

lib/helpers/android-bundle-validator-helper.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import * as semver from "semver";
21
import * as util from "util";
32
import { AndroidBundleValidatorMessages, TNS_ANDROID_RUNTIME_NAME } from "../constants";
43
import { VersionValidatorHelper } from "./version-validator-helper";
@@ -23,10 +22,11 @@ export class AndroidBundleValidatorHelper extends VersionValidatorHelper impleme
2322
if (this.$options.aab) {
2423
const androidRuntimeInfo = this.$projectDataService.getNSValue(projectData.projectDir, TNS_ANDROID_RUNTIME_NAME);
2524
const androidRuntimeVersion = androidRuntimeInfo ? androidRuntimeInfo.version : "";
26-
27-
if (androidRuntimeVersion &&
25+
const shouldThrowError = androidRuntimeVersion &&
2826
this.isValidVersion(androidRuntimeVersion) &&
29-
!this.compareCoerceVersions(androidRuntimeVersion, AndroidBundleValidatorHelper.MIN_RUNTIME_VERSION, semver.gte)) {
27+
this.isVersionLowerThan(androidRuntimeVersion, AndroidBundleValidatorHelper.MIN_RUNTIME_VERSION);
28+
29+
if (shouldThrowError) {
3030
this.$errors.failWithoutHelp(util.format(AndroidBundleValidatorMessages.NOT_SUPPORTED_RUNTIME_VERSION, AndroidBundleValidatorHelper.MIN_RUNTIME_VERSION));
3131
}
3232
}

lib/helpers/bundle-validator-helper.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import * as semver from "semver";
21
import * as util from "util";
32
import { BundleValidatorMessages } from "../constants";
43
import { VersionValidatorHelper } from "./version-validator-helper";
@@ -25,7 +24,8 @@ export class BundleValidatorHelper extends VersionValidatorHelper implements IBu
2524
}
2625

2726
const currentVersion = bundlerVersionInDependencies || bundlerVersionInDevDependencies;
28-
if (minSupportedVersion && this.isValidVersion(currentVersion) && !this.compareCoerceVersions(currentVersion, minSupportedVersion, semver.gte)) {
27+
const shouldThrowError = minSupportedVersion && this.isValidVersion(currentVersion) && this.isVersionLowerThan(currentVersion, minSupportedVersion);
28+
if (shouldThrowError) {
2929
this.$errors.failWithoutHelp(util.format(BundleValidatorMessages.NotSupportedVersion, minSupportedVersion));
3030
}
3131
}

lib/helpers/version-validator-helper.ts

+18-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,23 @@ export class VersionValidatorHelper {
66
return semver.valid(version) || semver.validRange(version);
77
}
88

9-
protected compareCoerceVersions(version: string, minVersion: string, comperator: Function): boolean {
10-
return comperator(semver.coerce(version), semver.coerce(minVersion));
9+
protected isVersionGreaterThan(v1: string, v2: string): boolean {
10+
return this.compareCoerceVersions(v1, v2, semver.gt);
11+
}
12+
13+
protected isVersionGreaterOrEqualThan(v1: string, v2: string): boolean {
14+
return this.compareCoerceVersions(v1, v2, semver.gte);
15+
}
16+
17+
protected isVersionLowerThan(v1: string, v2: string): boolean {
18+
return this.compareCoerceVersions(v1, v2, semver.lt);
19+
}
20+
21+
protected isVersionLowerOrEqualThan(v1: string, v2: string): boolean {
22+
return this.compareCoerceVersions(v1, v2, semver.lte);
23+
}
24+
25+
private compareCoerceVersions(version: string, minVersion: string, condition: Function): boolean {
26+
return condition(semver.coerce(version), semver.coerce(minVersion));
1127
}
1228
}

0 commit comments

Comments
 (0)