@@ -43,13 +43,13 @@ function getKarmaReporterPluginPath(reporterName) {
43
43
}
44
44
else {
45
45
var reporterPath = ( path . dirname ( reporterName ) === '.' ) ?
46
- path . resolve ( 'node_modules' , 'karma-' + reporterName + '-reporter' ) :
46
+ path . resolve ( 'node_modules' , 'karma-' + reporterName + '-reporter' ) :
47
47
reporterName ;
48
48
try {
49
49
require ( reporterPath ) ;
50
50
}
51
51
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.' ;
53
53
}
54
54
return reporterPath ;
55
55
}
@@ -68,13 +68,9 @@ function getKarmaReporterName(reporterName) {
68
68
throw 'Get Karma Reporter Name: Reporter name is unspecified' ;
69
69
}
70
70
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 ) ;
78
74
var match = karmaReporterMatchNameRegex . exec ( name ) ;
79
75
if ( ! ! match && match . length === 2 ) {
80
76
name = match [ 1 ] ;
@@ -115,18 +111,18 @@ function karmaCreateConfig(reporters, configFileName) {
115
111
var filesAppend = JSON . stringify ( files , null , ' ' ) ;
116
112
var reportersAppend = JSON . stringify ( reporters . map ( getKarmaReporterName ) , null , ' ' ) ;
117
113
var pluginsAppend = '[\n' + reporters . map ( function ( reporter ) {
118
- return 'require("' + getKarmaReporterPluginPath ( reporter ) + '")' ;
114
+ return 'require("' + getKarmaReporterPluginPath ( reporter ) + '")' ;
119
115
} ) . join ( ',\n ' ) + '\n]' ;
120
116
121
117
//aggregate and append to karma.conf.js in the project root folder
122
118
gulp
123
119
. src ( path . resolve ( configFileName ) )
124
120
. 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 ) ;
130
126
karmaConfigFile . contents = new Buffer ( contents ) ;
131
127
stream . push ( karmaConfigFile ) ;
132
128
} )
@@ -206,7 +202,7 @@ function karmaRun(reporters, bannerWidth) {
206
202
var yargsOptionDefiniton = {
207
203
key : 'karmareporter' ,
208
204
value : {
209
- describe : 'Specify a custom Karma reporter to use. ' +
205
+ describe : 'Specify a custom Karma reporter to use. ' +
210
206
'Either a locally npm installed module, or an asolute path to one.' ,
211
207
alias : [ 'k' ] ,
212
208
default : defaultReporterName ,
@@ -218,15 +214,14 @@ var checkKarmaReporter = yargs.createCheck()
218
214
return ! argv . help ;
219
215
} )
220
216
. 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
+ }
230
225
}
231
226
} ,
232
227
} )
0 commit comments