1
+ /* eslint-disable max-lines */
1
2
/* eslint-disable no-console */
2
3
import * as childProcess from 'child_process' ;
3
4
import * as fs from 'fs' ;
@@ -286,18 +287,21 @@ const recipeResults: RecipeResult[] = recipePaths.map(recipePath => {
286
287
} [ ] = process . env . CANARY_E2E_TEST ? recipe . canaryVersions ?? [ ] : recipe . versions ?? [ { } ] ;
287
288
288
289
const versionResults = versionsToRun . map ( ( { dependencyOverrides } ) => {
290
+ const packageJsonPath = path . resolve ( recipeDirname , 'package.json' ) ;
291
+ const packageJsonBackupPath = path . resolve ( recipeDirname , 'package.json.bak' ) ;
292
+
289
293
if ( dependencyOverrides ) {
290
294
// Back up original package.json
291
- fs . copyFileSync ( path . resolve ( recipeDirname , 'package.json' ) , path . resolve ( recipeDirname , 'package.json.bak' ) ) ;
295
+ fs . copyFileSync ( packageJsonPath , packageJsonBackupPath ) ;
292
296
293
297
// Override dependencies
294
298
const packageJson : { dependencies ?: Record < string , string > } = JSON . parse (
295
- fs . readFileSync ( path . resolve ( recipeDirname , 'package.json' ) , { encoding : 'utf-8' } ) ,
299
+ fs . readFileSync ( packageJsonPath , { encoding : 'utf-8' } ) ,
296
300
) ;
297
301
packageJson . dependencies = packageJson . dependencies
298
302
? { ...packageJson . dependencies , ...dependencyOverrides }
299
303
: dependencyOverrides ;
300
- fs . writeFileSync ( path . resolve ( recipeDirname , 'package.json' ) , JSON . stringify ( packageJson , null , 2 ) , {
304
+ fs . writeFileSync ( packageJsonPath , JSON . stringify ( packageJson , null , 2 ) , {
301
305
encoding : 'utf-8' ,
302
306
} ) ;
303
307
}
@@ -307,9 +311,9 @@ const recipeResults: RecipeResult[] = recipePaths.map(recipePath => {
307
311
} finally {
308
312
if ( dependencyOverrides ) {
309
313
// Restore original package.json
310
- fs . rmSync ( path . resolve ( recipeDirname , 'package.json' ) , { force : true } ) ;
311
- fs . copyFileSync ( path . resolve ( recipeDirname , 'package.json.bak' ) , path . resolve ( recipeDirname , 'package.json' ) ) ;
312
- fs . rmSync ( path . resolve ( recipeDirname , 'package.json.bak' ) , { force : true } ) ;
314
+ fs . rmSync ( packageJsonPath , { force : true } ) ;
315
+ fs . copyFileSync ( packageJsonBackupPath , packageJsonPath ) ;
316
+ fs . rmSync ( packageJsonBackupPath , { force : true } ) ;
313
317
}
314
318
}
315
319
} ) ;
@@ -349,11 +353,9 @@ recipeResults.forEach(recipeResult => {
349
353
} ) ;
350
354
} ) ;
351
355
352
- groupCIOutput ( 'Cleanup' , ( ) => {
353
- // Stop test registry
354
- childProcess . spawnSync ( `docker stop ${ TEST_REGISTRY_CONTAINER_NAME } ` , { encoding : 'utf8' , stdio : 'ignore' } ) ;
355
- console . log ( 'Successfully stopped test registry container' ) ; // Output from command above is not good so we `ignore` it and emit our own
356
- } ) ;
356
+ // Stop test registry
357
+ childProcess . spawnSync ( `docker stop ${ TEST_REGISTRY_CONTAINER_NAME } ` , { encoding : 'utf8' , stdio : 'ignore' } ) ;
358
+ console . log ( 'Successfully stopped test registry container' ) ; // Output from command above is not good so we `ignore` it and emit our own
357
359
358
360
if ( processShouldExitWithError ) {
359
361
console . log ( 'Not all tests succeeded.' ) ;
0 commit comments