@@ -47,8 +47,8 @@ export function prepareTestEnv(rootPath: string, logsRootPath: string) {
4747/**
4848 * Sets up the test environment for Electron or Web e2e tests.
4949 */
50- function initializeTestEnvironment ( rootPath = process . env . ROOT_PATH || 'ROOT_PATH not set initTestEnv' , logger : Logger ) : string | null {
51- let version : string | null = null ;
50+ function initializeTestEnvironment ( rootPath = process . env . ROOT_PATH || 'ROOT_PATH not set initTestEnv' , logger : Logger ) : PositronVersion | null {
51+ let version : PositronVersion | null = null ;
5252
5353 //
5454 // #### E2E: Electron Tests ####
@@ -61,7 +61,9 @@ function initializeTestEnvironment(rootPath = process.env.ROOT_PATH || 'ROOT_PAT
6161 if ( testCodePath ) {
6262 electronPath = getBuildElectronPath ( testCodePath ) ;
6363 version = getPositronVersion ( testCodePath ) ;
64- console . log ( 'POSITRON VERSION:' , version ) ;
64+ if ( version ) {
65+ console . log ( `POSITRON VERSION: ${ version . positronVersion } -${ version . buildNumber } ` ) ;
66+ }
6567 } else {
6668 testCodePath = getDevElectronPath ( ) ;
6769 electronPath = testCodePath ;
@@ -117,7 +119,11 @@ function prepareTestDataDirectory() {
117119 mkdirp . sync ( TEST_DATA_PATH ) ;
118120}
119121
120- function getPositronVersion ( testCodePath : string ) : string | null {
122+ export function getPositronVersion ( testCodePath = process . env . BUILD || '' ) : PositronVersion | null {
123+ if ( ! testCodePath ) {
124+ return null ;
125+ }
126+
121127 let productJsonPath ;
122128 switch ( process . platform ) {
123129 case 'darwin' :
@@ -133,14 +139,27 @@ function getPositronVersion(testCodePath: string): string | null {
133139 return null ;
134140 }
135141
136- // Read and parse the JSON file
137- const productJson = JSON . parse ( fs . readFileSync ( productJsonPath , 'utf8' ) ) ;
142+ try {
143+ // Read and parse the JSON file
144+ const productJson = JSON . parse ( fs . readFileSync ( productJsonPath , 'utf8' ) ) ;
145+
146+ // Return both version and build number properties
147+ const positronVersion = productJson . positronVersion || null ;
148+ const buildNumber = productJson . positronBuildNumber || null ;
138149
139- // Return the `positronVersion` property if it exists, otherwise log an error
140- if ( productJson . positronVersion ) {
141- return productJson . positronVersion ;
142- } else {
143- console . error ( 'positronVersion not found in product.json.' ) ;
150+ if ( ! positronVersion ) {
151+ throw new Error ( 'positronVersion not found in product.json.' ) ;
152+ }
153+
154+ if ( ! buildNumber ) {
155+ console . error ( 'positronBuildNumber not found in product.json.' ) ;
156+ }
157+
158+ return { positronVersion, buildNumber } ;
159+ } catch ( error ) {
160+ console . error ( 'Error reading product.json:' , error ) ;
144161 return null ;
145162 }
146163}
164+
165+ type PositronVersion = { positronVersion : string | null , buildNumber : string | null } ;
0 commit comments