@@ -286,23 +286,26 @@ export class MigrateController extends UpdateControllerBase implements IMigrateC
286
286
287
287
private async migrateUnitTestRunner ( projectData : IProjectData , migrationBackupDirPath : string ) : Promise < IMigrationDependency [ ] > {
288
288
// Migrate karma.conf.js
289
- const oldKarmaContent = this . $fs . readText ( path . join ( migrationBackupDirPath , constants . KARMA_CONFIG_NAME ) ) ;
289
+ const pathToKarmaConfig = path . join ( migrationBackupDirPath , constants . KARMA_CONFIG_NAME ) ;
290
+ if ( this . $fs . exists ( pathToKarmaConfig ) ) {
291
+ const oldKarmaContent = this . $fs . readText ( pathToKarmaConfig ) ;
290
292
291
- const regExp = / f r a m e w o r k s : \s + \[ ( [ \S \s ] * ?) \] / g;
292
- const matches = regExp . exec ( oldKarmaContent ) ;
293
- const frameworks = ( matches && matches [ 1 ] && matches [ 1 ] . trim ( ) ) || '["jasmine"]' ;
293
+ const regExp = / f r a m e w o r k s : \s + \[ ( [ \S \s ] * ?) \] / g;
294
+ const matches = regExp . exec ( oldKarmaContent ) ;
295
+ const frameworks = ( matches && matches [ 1 ] && matches [ 1 ] . trim ( ) ) || '["jasmine"]' ;
294
296
295
- const testsDir = path . join ( projectData . appDirectoryPath , 'tests' ) ;
296
- const relativeTestsDir = path . relative ( projectData . projectDir , testsDir ) ;
297
- const testFiles = `'${ fromWindowsRelativePathToUnix ( relativeTestsDir ) } /**/*.*'` ;
297
+ const testsDir = path . join ( projectData . appDirectoryPath , 'tests' ) ;
298
+ const relativeTestsDir = path . relative ( projectData . projectDir , testsDir ) ;
299
+ const testFiles = `'${ fromWindowsRelativePathToUnix ( relativeTestsDir ) } /**/*.*'` ;
298
300
299
- const karmaConfTemplate = this . $resources . readText ( 'test/karma.conf.js' ) ;
300
- const karmaConf = _ . template ( karmaConfTemplate ) ( { frameworks, testFiles } ) ;
301
- this . $fs . writeFile ( path . join ( projectData . projectDir , constants . KARMA_CONFIG_NAME ) , karmaConf ) ;
301
+ const karmaConfTemplate = this . $resources . readText ( 'test/karma.conf.js' ) ;
302
+ const karmaConf = _ . template ( karmaConfTemplate ) ( { frameworks, testFiles } ) ;
303
+ this . $fs . writeFile ( path . join ( projectData . projectDir , constants . KARMA_CONFIG_NAME ) , karmaConf ) ;
304
+ }
302
305
303
306
// Dependencies to migrate
304
307
const dependencies = [
305
- { packageName : "karma-webpack" , verifiedVersion : "3.0.5" , isDev : true , shouldAddIfMissing : ! this . hasDependency ( { packageName : "karma-webpack" , isDev : true } , projectData ) } ,
308
+ { packageName : "karma-webpack" , verifiedVersion : "3.0.5" , isDev : true , shouldAddIfMissing : true } ,
306
309
{ packageName : "karma-jasmine" , verifiedVersion : "2.0.1" , isDev : true } ,
307
310
{ packageName : "karma-mocha" , verifiedVersion : "1.3.0" , isDev : true } ,
308
311
{ packageName : "karma-chai" , verifiedVersion : "0.1.0" , isDev : true } ,
0 commit comments