Skip to content

Commit c30d685

Browse files
Merge pull request #1356 from NativeScript/vladimirov/improve-init-command
Init command should not force tns-core-modules version
2 parents 2176482 + 967da67 commit c30d685

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

lib/services/init-service.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,9 @@ export class InitService implements IInitService {
6060
if(!dependencies) {
6161
projectData.dependencies = Object.create(null);
6262
}
63-
projectData.dependencies[constants.TNS_CORE_MODULES_NAME] = this.getVersionData(constants.TNS_CORE_MODULES_NAME).wait()["version"];
63+
// In case console is interactive and --force is not specified, do not read the version from package.json, show all available versions to the user.
64+
let tnsCoreModulesVersionInPackageJson = this.useDefaultValue ? projectData.dependencies[constants.TNS_CORE_MODULES_NAME] : null;
65+
projectData.dependencies[constants.TNS_CORE_MODULES_NAME] = this.$options.tnsModulesVersion || tnsCoreModulesVersionInPackageJson || this.getVersionData(constants.TNS_CORE_MODULES_NAME).wait()["version"];
6466

6567
this.$fs.writeJson(this.projectFilePath, projectData).wait();
6668
} catch(err) {
@@ -106,7 +108,7 @@ export class InitService implements IInitService {
106108
let data = this.$npm.view(packageName, "versions").wait();
107109
let versions = _.filter(data[latestVersion].versions, (version: string) => semver.gte(version, InitService.MIN_SUPPORTED_FRAMEWORK_VERSIONS[packageName]));
108110
if(versions.length === 1) {
109-
this.$logger.info(`Only ${versions[0]} version is available for ${packageName} framework.`);
111+
this.$logger.info(`Only ${versions[0]} version is available for ${packageName}.`);
110112
return this.buildVersionData(versions[0]);
111113
}
112114
let sortedVersions = versions.sort(helpers.versionCompare).reverse();

0 commit comments

Comments
 (0)