1+ /* eslint-disable max-lines */
12/* eslint-disable no-console */
23import * as childProcess from 'child_process' ;
34import * as fs from 'fs' ;
@@ -286,18 +287,21 @@ const recipeResults: RecipeResult[] = recipePaths.map(recipePath => {
286287 } [ ] = process . env . CANARY_E2E_TEST ? recipe . canaryVersions ?? [ ] : recipe . versions ?? [ { } ] ;
287288
288289 const versionResults = versionsToRun . map ( ( { dependencyOverrides } ) => {
290+ const packageJsonPath = path . resolve ( recipeDirname , 'package.json' ) ;
291+ const packageJsonBackupPath = path . resolve ( recipeDirname , 'package.json.bak' ) ;
292+
289293 if ( dependencyOverrides ) {
290294 // Back up original package.json
291- fs . copyFileSync ( path . resolve ( recipeDirname , 'package.json' ) , path . resolve ( recipeDirname , 'package.json.bak' ) ) ;
295+ fs . copyFileSync ( packageJsonPath , packageJsonBackupPath ) ;
292296
293297 // Override dependencies
294298 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' } ) ,
296300 ) ;
297301 packageJson . dependencies = packageJson . dependencies
298302 ? { ...packageJson . dependencies , ...dependencyOverrides }
299303 : dependencyOverrides ;
300- fs . writeFileSync ( path . resolve ( recipeDirname , 'package.json' ) , JSON . stringify ( packageJson , null , 2 ) , {
304+ fs . writeFileSync ( packageJsonPath , JSON . stringify ( packageJson , null , 2 ) , {
301305 encoding : 'utf-8' ,
302306 } ) ;
303307 }
@@ -307,9 +311,9 @@ const recipeResults: RecipeResult[] = recipePaths.map(recipePath => {
307311 } finally {
308312 if ( dependencyOverrides ) {
309313 // 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 } ) ;
313317 }
314318 }
315319 } ) ;
@@ -349,11 +353,9 @@ recipeResults.forEach(recipeResult => {
349353 } ) ;
350354} ) ;
351355
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
357359
358360if ( processShouldExitWithError ) {
359361 console . log ( 'Not all tests succeeded.' ) ;
0 commit comments