Skip to content

Commit 1502957

Browse files
committed
chore: fix PR comments
1 parent 8c11335 commit 1502957

File tree

3 files changed

+19
-11
lines changed

3 files changed

+19
-11
lines changed

lib/declarations.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -841,7 +841,7 @@ interface IDeployCommandHelper {
841841
interface IBundleValidatorHelper {
842842
/**
843843
* Validates bundling options.
844-
* In case when minSupportedVersion is provided, gets the current version of nativescript-dev-webpack from package json and compares with the provided version.
844+
* In case when minSupportedVersion is provided, gets the current version of nativescript-dev-webpack from package.json and compares with the provided version.
845845
* @param {string} minSupportedVersion the minimum supported version of nativescript-dev-webpack
846846
* @return {void}
847847
*/

lib/helpers/bundle-validator-helper.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,17 @@ export class BundleValidatorHelper implements IBundleValidatorHelper {
1616
public validate(minSupportedVersion?: string): void {
1717
if (this.$options.bundle) {
1818
const bundlePluginName = this.bundlersMap[this.$options.bundle];
19-
const hasBundlerPluginAsDependency = this.$projectData.dependencies && this.$projectData.dependencies[bundlePluginName];
20-
const hasBundlerPluginAsDevDependency = this.$projectData.devDependencies && this.$projectData.devDependencies[bundlePluginName];
21-
if (!bundlePluginName || (!hasBundlerPluginAsDependency && !hasBundlerPluginAsDevDependency)) {
19+
const bundlerVersionInDependencies = this.$projectData.dependencies && this.$projectData.dependencies[bundlePluginName];
20+
const bundlerVersionInDevDependencies = this.$projectData.devDependencies && this.$projectData.devDependencies[bundlePluginName];
21+
if (!bundlePluginName || (!bundlerVersionInDependencies && !bundlerVersionInDevDependencies)) {
2222
this.$errors.fail(BundleValidatorMessages.MissingBundlePlugin);
2323
}
2424

2525
if (minSupportedVersion) {
26-
const currentVersion = hasBundlerPluginAsDependency || hasBundlerPluginAsDevDependency;
26+
const currentVersion = bundlerVersionInDependencies || bundlerVersionInDevDependencies;
2727
const isBundleSupported = semver.gte(semver.coerce(currentVersion), semver.coerce(minSupportedVersion));
2828
if (!isBundleSupported) {
29-
this.$errors.fail(util.format(BundleValidatorMessages.NotSupportedVersion, minSupportedVersion));
29+
this.$errors.failWithoutHelp(util.format(BundleValidatorMessages.NotSupportedVersion, minSupportedVersion));
3030
}
3131
}
3232
}

test/helpers/bundle-validator-helper.ts

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,16 @@ function createTestInjector(options: { dependencies?: IStringDictionary, devDepe
2222
devDependencies: options.devDependencies
2323
});
2424
testInjector.register("errors", {
25-
fail: (err: string) => error = err
25+
fail: (err: string) => error = err,
26+
failWithoutHelp: (err: string) => error = err
2627
});
2728
testInjector.register("options", ({ bundle: "webpack" }));
2829
testInjector.register("bundleValidatorHelper", BundleValidatorHelper);
2930

3031
return testInjector;
3132
}
3233

33-
describe.only("BundleValidatorHelper", () => {
34+
describe("BundleValidatorHelper", () => {
3435
beforeEach(() => error = null);
3536

3637
let testCases: ITestCase[] = [
@@ -52,25 +53,32 @@ describe.only("BundleValidatorHelper", () => {
5253
expectedError: null
5354
},
5455
{
55-
name: `should not throw an error when webpack's version is grather than minSupportedVersion in case when webpack is installed as ${key}`,
56+
name: `should not throw an error when webpack's version is greater than minSupportedVersion when webpack is installed as ${key}`,
5657
isDependency,
5758
currentWebpackVersion: "0.13.1",
5859
minSupportedWebpackVersion: "0.13.0",
5960
expectedError: null
6061
},
6162
{
62-
name: `should not throw an error when webpack's version is equal to minSupportedVersion in case when webpack is installed as ${key}`,
63+
name: `should not throw an error when webpack's version is equal to minSupportedVersion when webpack is installed as ${key}`,
6364
isDependency,
6465
currentWebpackVersion: "0.10.0",
6566
minSupportedWebpackVersion: "0.10.0",
6667
expectedError: null
6768
},
6869
{
69-
name: `should throw an error when webpack's version is lower than minSupportedVersion in case when webpack is installed as ${key}`,
70+
name: `should throw an error when webpack's version is lower than minSupportedVersion when webpack is installed as ${key}`,
7071
isDependency,
7172
currentWebpackVersion: "0.17.0",
7273
minSupportedWebpackVersion: "0.18.0",
7374
expectedError: format(BundleValidatorMessages.NotSupportedVersion, "0.18.0")
75+
},
76+
{
77+
name: `should not throw an error when prerelease version of webpack is installed as ${key}`,
78+
isDependency,
79+
currentWebpackVersion: "0.17.0-2018-09-28-173604-01",
80+
minSupportedWebpackVersion: "0.17.0",
81+
expectedError: null
7482
}
7583
]);
7684
});

0 commit comments

Comments
 (0)