Skip to content

Commit dbe20cd

Browse files
Merge pull request #3706 from NativeScript/vladimirov/merge-rel-master
chore: Merge release in master
2 parents b1cad72 + 27a2c4e commit dbe20cd

File tree

2 files changed

+41
-9
lines changed

2 files changed

+41
-9
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
NativeScript CLI Changelog
22
================
33

4+
4.1.2 (2018, June 26)
5+
==
6+
7+
### Fixed
8+
9+
* [Fixed #2283](https://github.com/NativeScript/nativescript-cli/issues/2283): On adding test frameworks their peerDependencies are not installed
10+
* [Fixed #3689](https://github.com/NativeScript/nativescript-cli/issues/3689): `tns test <platform>` throws exception
11+
12+
413
4.1.1 (2018, June 19)
514
==
615

lib/commands/test-init.ts

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@ class TestInitCommand implements ICommand {
55
public allowedParameters: ICommandParameter[] = [];
66

77
private frameworkDependencies: IDictionary<string[]> = {
8-
mocha: ['chai'],
8+
mocha: ['karma-chai', 'mocha'],
9+
};
10+
11+
private karmaConfigAdditionalFrameworks: IDictionary<string[]> = {
12+
mocha: ['chai']
913
};
1014

1115
constructor(private $npm: INodePackageManager,
@@ -30,19 +34,38 @@ class TestInitCommand implements ICommand {
3034
}
3135

3236
const dependencies = this.frameworkDependencies[frameworkToInstall] || [];
33-
const modulesToInstall = ['karma', 'karma-' + frameworkToInstall, 'karma-nativescript-launcher'].concat(dependencies.map(f => 'karma-' + f));
37+
const modulesToInstall: IDependencyInformation[] = [
38+
{
39+
name: 'karma',
40+
// Hardcode the version unitl https://github.com/karma-runner/karma/issues/3052 is fixed
41+
version: "2.0.2"
42+
},
43+
{
44+
name: `karma-${frameworkToInstall}`
45+
},
46+
{
47+
name: 'karma-nativescript-launcher'
48+
}
49+
];
50+
51+
modulesToInstall.push(...dependencies.map(f => ({ name: f })));
3452

3553
for (const mod of modulesToInstall) {
36-
await this.$npm.install(mod, projectDir, {
54+
let moduleToInstall = mod.name;
55+
if (mod.version) {
56+
moduleToInstall += `@${mod.version}`;
57+
}
58+
await this.$npm.install(moduleToInstall, projectDir, {
3759
'save-dev': true,
60+
'save-exact': true,
3861
optional: false,
3962
disableNpmInstall: this.$options.disableNpmInstall,
4063
frameworkPath: this.$options.frameworkPath,
4164
ignoreScripts: this.$options.ignoreScripts,
4265
path: this.$options.path
4366
});
4467

45-
const modulePath = path.join(projectDir, "node_modules", mod);
68+
const modulePath = path.join(projectDir, "node_modules", mod.name);
4669
const modulePackageJsonPath = path.join(modulePath, "package.json");
4770
const modulePackageJsonContent = this.$fs.readJson(modulePackageJsonPath);
4871
const modulePeerDependencies = modulePackageJsonContent.peerDependencies || {};
@@ -55,6 +78,7 @@ class TestInitCommand implements ICommand {
5578
try {
5679
await this.$npm.install(`${peerDependency}@${dependencyVersion}`, projectDir, {
5780
'save-dev': true,
81+
'save-exact': true,
5882
disableNpmInstall: false,
5983
frameworkPath: this.$options.frameworkPath,
6084
ignoreScripts: this.$options.ignoreScripts,
@@ -77,12 +101,11 @@ class TestInitCommand implements ICommand {
77101

78102
this.$fs.ensureDirectoryExists(testsDir);
79103

104+
const frameworks = [frameworkToInstall].concat(this.karmaConfigAdditionalFrameworks[frameworkToInstall] || [])
105+
.map(fw => `'${fw}'`)
106+
.join(', ');
80107
const karmaConfTemplate = this.$resources.readText('test/karma.conf.js');
81-
const karmaConf = _.template(karmaConfTemplate)({
82-
frameworks: [frameworkToInstall].concat(dependencies)
83-
.map(fw => `'${fw}'`)
84-
.join(', ')
85-
});
108+
const karmaConf = _.template(karmaConfTemplate)({ frameworks });
86109

87110
this.$fs.writeFile(path.join(projectDir, 'karma.conf.js'), karmaConf);
88111

0 commit comments

Comments
 (0)