-
-
Notifications
You must be signed in to change notification settings - Fork 194
Description
Environment
Provide version numbers for the following components (information can be retrieved by running tns info
in your project folder or by inspecting the package.json
of the project):
- CLI: 5.0.0-2018-10-11-12463
- Cross-platform modules: rc
Describe the bug
If the version of some plugin in the package.json is specified with tag (f.e. rc
) instead of version (f.e. 5.0.0
), the tns preview
command fails with:
TypeError: Cannot read property 'major' of null
at PreviewAppPluginsService.getWarningForPluginCore (/home/sis0k0/nativescript-cli/lib/services/livesync/playground/preview-app-plugins-service.ts:82:30)
The PreviewAppPluginsService
uses semver
to check some stuff with the versions of the plugins in the package.json. However, semver.coerce('rc')
returns null
and breaks the following logic.
nativescript-cli/lib/services/livesync/playground/preview-app-plugins-service.ts
Lines 74 to 91 in b9bfc68
private getWarningForPluginCore(localPlugin: string, localPluginVersion: string, devicePluginVersion: string, deviceId: string): string { | |
this.$logger.trace(`Comparing plugin ${localPlugin} with localPluginVersion ${localPluginVersion} and devicePluginVersion ${devicePluginVersion}`); | |
if (devicePluginVersion) { | |
const localPluginVersionData = semver.coerce(localPluginVersion); | |
const devicePluginVersionData = semver.coerce(devicePluginVersion); | |
if (localPluginVersionData.major !== devicePluginVersionData.major) { | |
return util.format(PluginComparisonMessages.LOCAL_PLUGIN_WITH_DIFFERENCE_IN_MAJOR_VERSION, localPlugin, localPluginVersion, devicePluginVersion); | |
} else if (localPluginVersionData.minor > devicePluginVersionData.minor) { | |
return util.format(PluginComparisonMessages.LOCAL_PLUGIN_WITH_GREATHER_MINOR_VERSION, localPlugin, localPluginVersion, devicePluginVersion); | |
} | |
return null; | |
} | |
return util.format(PluginComparisonMessages.PLUGIN_NOT_INCLUDED_IN_PREVIEW_APP, localPlugin, deviceId); | |
} |
To Reproduce
- Create a hello-world app.
- Add this dependency to your package.json:
...
"dependencies": {
"tns-core-modules": "rc",
...
}
- Run
tns preview
and scan the barcode.
Expected behavior
To ignore the above check if the tag is beta
, rc
or next
.
I can submit a PR if you agree that's the correct behaviour.