@@ -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) {
206202var 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 } )
0 commit comments