@@ -71,12 +71,10 @@ describe('A root logger.', () => {
7171
7272describe ( 'Logger version handling' , ( ) => {
7373 test ( 'Should not fail if package.json does not exist' , ( ) => {
74- const packageFilePath = path . resolve ( __dirname , 'package.json' ) ;
75-
7674 // Temporarily rename package.json to simulate its absence
77- const tempFilePath = `${ packageFilePath } .bak` ;
78- if ( fs . existsSync ( packageFilePath ) ) {
79- fs . renameSync ( packageFilePath , tempFilePath ) ;
75+ const tempFilePath = `${ versionFilePath } .bak` ;
76+ if ( fs . existsSync ( versionFilePath ) ) {
77+ fs . renameSync ( versionFilePath , tempFilePath ) ;
8078 }
8179
8280 setContext ( context , 'unit-test' ) ;
@@ -89,17 +87,15 @@ describe('Logger version handling', () => {
8987
9088 // Restore package.json
9189 if ( fs . existsSync ( tempFilePath ) ) {
92- fs . renameSync ( tempFilePath , packageFilePath ) ;
90+ fs . renameSync ( tempFilePath , versionFilePath ) ;
9391 }
9492 } ) ;
9593
9694 test ( 'Should log version from package.json' , ( ) => {
97- const packageFilePath = path . resolve ( __dirname , 'package.json' ) ;
98-
9995 // Create a mock package.json file
100- const originalPackageData = fs . existsSync ( packageFilePath ) ? fs . readFileSync ( packageFilePath , 'utf-8' ) : null ;
96+ const originalPackageData = fs . existsSync ( versionFilePath ) ? fs . readFileSync ( packageFilePath , 'utf-8' ) : null ;
10197 const mockPackageData = JSON . stringify ( { version : '1.0.0' } ) ;
102- fs . writeFileSync ( packageFilePath , mockPackageData ) ;
98+ fs . writeFileSync ( versionFilePath , mockPackageData ) ;
10399
104100 setContext ( context , 'unit-test' ) ;
105101
@@ -111,9 +107,9 @@ describe('Logger version handling', () => {
111107
112108 // Restore the original package.json file
113109 if ( originalPackageData ) {
114- fs . writeFileSync ( packageFilePath , originalPackageData ) ;
110+ fs . writeFileSync ( versionFilePath , originalPackageData ) ;
115111 } else {
116- fs . unlinkSync ( packageFilePath ) ;
112+ fs . unlinkSync ( versionFilePath ) ;
117113 }
118114 } ) ;
119115} ) ;
0 commit comments