Skip to content

Commit 64eb455

Browse files
committed
fix: validate correctly when next is written as a version of nativescript-dev-webpack in package.json
1 parent 61fae69 commit 64eb455

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

lib/helpers/bundle-validator-helper.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,12 @@ export class BundleValidatorHelper implements IBundleValidatorHelper {
2424

2525
if (minSupportedVersion) {
2626
const currentVersion = bundlerVersionInDependencies || bundlerVersionInDevDependencies;
27-
const isBundleSupported = semver.gte(semver.coerce(currentVersion), semver.coerce(minSupportedVersion));
28-
if (!isBundleSupported) {
29-
this.$errors.failWithoutHelp(util.format(BundleValidatorMessages.NotSupportedVersion, minSupportedVersion));
27+
const shouldSkipCheck = !semver.valid(currentVersion) && !semver.validRange(currentVersion);
28+
if (!shouldSkipCheck) {
29+
const isBundleSupported = semver.gte(semver.coerce(currentVersion), semver.coerce(minSupportedVersion));
30+
if (!isBundleSupported) {
31+
this.$errors.failWithoutHelp(util.format(BundleValidatorMessages.NotSupportedVersion, minSupportedVersion));
32+
}
3033
}
3134
}
3235
}

test/helpers/bundle-validator-helper.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,13 @@ describe("BundleValidatorHelper", () => {
7979
currentWebpackVersion: "0.17.0-2018-09-28-173604-01",
8080
minSupportedWebpackVersion: "0.17.0",
8181
expectedError: null
82+
},
83+
{
84+
name: `should not throw an error when next version of webpack is installed as ${key}`,
85+
isDependency,
86+
currentWebpackVersion: "next",
87+
minSupportedWebpackVersion: "0.17.0",
88+
expectedError: null
8289
}
8390
]);
8491
});

0 commit comments

Comments
 (0)