Skip to content

Commit fe367a0

Browse files
committed
=BG= minor - requested code style changes
1 parent f5188e9 commit fe367a0

File tree

4 files changed

+26
-30
lines changed

4 files changed

+26
-30
lines changed

lib/test/karma.js

Lines changed: 20 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,13 @@ function getKarmaReporterPluginPath(reporterName) {
4343
}
4444
else {
4545
var reporterPath = (path.dirname(reporterName) === '.') ?
46-
path.resolve('node_modules', 'karma-'+reporterName+'-reporter') :
46+
path.resolve('node_modules', 'karma-' + reporterName + '-reporter') :
4747
reporterName;
4848
try {
4949
require(reporterPath);
5050
}
5151
catch (ex) {
52-
throw 'Get Karma Reporter Plugin Path: Attempt to require reporter from path '+reporterPath+' with no success.';
52+
throw 'Get Karma Reporter Plugin Path: Attempt to require reporter from path ' + reporterPath + ' with no success.';
5353
}
5454
return reporterPath;
5555
}
@@ -68,13 +68,9 @@ function getKarmaReporterName(reporterName) {
6868
throw 'Get Karma Reporter Name: Reporter name is unspecified';
6969
}
7070

71-
var name;
72-
if (path.dirname(reporterName) === '.') {
73-
name = reporterName;
74-
}
75-
else {
76-
name = path.basename(reporterName);
77-
}
71+
var name = (path.dirname(reporterName) === '.') ?
72+
reporterName :
73+
path.basename(reporterName);
7874
var match = karmaReporterMatchNameRegex.exec(name);
7975
if (!!match && match.length === 2) {
8076
name = match[1];
@@ -115,18 +111,18 @@ function karmaCreateConfig(reporters, configFileName) {
115111
var filesAppend = JSON.stringify(files, null, ' ');
116112
var reportersAppend = JSON.stringify(reporters.map(getKarmaReporterName), null, ' ');
117113
var pluginsAppend = '[\n' + reporters.map(function(reporter) {
118-
return 'require("'+getKarmaReporterPluginPath(reporter)+'")';
114+
return 'require("' + getKarmaReporterPluginPath(reporter) + '")';
119115
}).join(',\n ') + '\n]';
120116

121117
//aggregate and append to karma.conf.js in the project root folder
122118
gulp
123119
.src(path.resolve(configFileName))
124120
.on('data', function(karmaConfigFile) {
125-
var contents = karmaConfigFile.contents.toString();
126-
contents = contents.replace(filesAppendRegex, filesAppend);
127-
contents = contents.replace(reportersAppendRegex, reportersAppend);
128-
contents = contents.replace(reportersAppendRegex, reportersAppend);
129-
contents = contents.replace(pluginsAppendRegex, pluginsAppend);
121+
var contents = karmaConfigFile.contents.toString()
122+
.replace(filesAppendRegex, filesAppend)
123+
.replace(reportersAppendRegex, reportersAppend)
124+
.replace(reportersAppendRegex, reportersAppend)
125+
.replace(pluginsAppendRegex, pluginsAppend);
130126
karmaConfigFile.contents = new Buffer(contents);
131127
stream.push(karmaConfigFile);
132128
})
@@ -206,7 +202,7 @@ function karmaRun(reporters, bannerWidth) {
206202
var yargsOptionDefiniton = {
207203
key: 'karmareporter',
208204
value: {
209-
describe: 'Specify a custom Karma reporter to use. '+
205+
describe: 'Specify a custom Karma reporter to use. ' +
210206
'Either a locally npm installed module, or an asolute path to one.',
211207
alias: ['k'],
212208
default: defaultReporterName,
@@ -218,15 +214,14 @@ var checkKarmaReporter = yargs.createCheck()
218214
return !argv.help;
219215
})
220216
.withTest({
221-
'karmareporter': function(value) {
222-
if (typeof value === 'undefined') {
223-
return;
224-
}
225-
try {
226-
getKarmaReporterPluginPath(value);
227-
}
228-
catch (ex) {
229-
return 'Illegal value for "reporter"\n'+ex;
217+
karmareporter: function(value) {
218+
if (typeof value !== 'undefined') {
219+
try {
220+
getKarmaReporterPluginPath(value);
221+
}
222+
catch (ex) {
223+
return 'Illegal value for "reporter"\n' + ex;
224+
}
230225
}
231226
},
232227
})

lib/util/jshint-reporter.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ var checkJsHintReporter = yargs.createCheck()
6969
return !argv.help;
7070
})
7171
.withTest({
72-
'reporter': function(value) {
72+
reporter: function(value) {
7373
if (typeof value === 'undefined') {
7474
return;
7575
}

tasks/javascript.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ gulp.task('javascript:unit', function () {
120120
reporters = Array;
121121
}
122122
else if (typeof reporters === 'string' &&
123-
reporters !== karma.yargsOption.value.default) {
123+
reporters !== karma.yargsOption.value.default) {
124124
reporters = [reporters];
125125
}
126126
else {

templates/angularity/karma.conf.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@ module.exports = function(config) {
1919
// list of files to exclude
2020
exclude: [],
2121

22-
// register any plugins which are not siblings of karma in angularity global installation
23-
// and thus need to be registered manually
24-
plugins: config.plugins.concat(/*ANGULARITY_PLUGIN_LIST*/),
22+
// register any plugins which are not siblings of karma in angularity global
23+
// installation and thus need to be registered manually
24+
// append to existing value to preserve plugins loaded automatically
25+
plugins: [].concat(config.plugins, /*ANGULARITY_PLUGIN_LIST*/),
2526

2627
// use dots reporter, as travis terminal does not support escaping sequences
2728
// possible values: 'dots', 'progress', 'junit', 'teamcity'

0 commit comments

Comments
 (0)