@@ -342,30 +342,48 @@ module.exports.cleanSessionDataOnShutdown = () => {
342
342
return p
343
343
}
344
344
345
+ const safeGetVersion = ( fieldName , getFieldVersion ) => {
346
+ const versionField = {
347
+ name : fieldName ,
348
+ version : undefined
349
+ }
350
+ try {
351
+ if ( typeof getFieldVersion === 'function' ) {
352
+ versionField . version = getFieldVersion ( )
353
+ return versionField
354
+ }
355
+ console . log ( 'ERROR getting value for field ' + fieldName + ' in sessionStore::setVersionInformation(): ' , getFieldVersion , ' is not a function' )
356
+ } catch ( e ) {
357
+ console . log ( 'ERROR getting value for field ' + fieldName + ' in sessionStore::setVersionInformation(): ' , e )
358
+ }
359
+ return versionField
360
+ }
361
+
345
362
/**
346
363
* version information (shown on about:brave)
347
364
*/
348
365
const setVersionInformation = ( data ) => {
349
- try {
350
- const os = require ( 'os' )
351
- const versionInformation = [
352
- { name : 'Brave' , version : app . getVersion ( ) } ,
353
- { name : 'rev' , version : Channel . browserLaptopRev ( ) } ,
354
- { name : 'Muon' , version : process . versions [ 'atom-shell' ] } ,
355
- { name : 'libchromiumcontent' , version : process . versions [ 'chrome' ] } ,
356
- { name : 'V8' , version : process . versions . v8 } ,
357
- { name : 'Node.js' , version : process . versions . node } ,
358
- { name : 'Update Channel' , version : Channel . channel ( ) } ,
359
- { name : 'os.platform' , version : os . platform ( ) } ,
360
- { name : 'os.release' , version : os . release ( ) } ,
361
- { name : 'os.arch' , version : os . arch ( ) }
362
- ]
363
- data . about = data . about || { }
364
- data . about . brave = {
365
- versionInformation : versionInformation
366
- }
367
- } catch ( e ) {
368
- console . log ( 'ERROR calling sessionStore::setVersionInformation(): ' , e )
366
+ const versionFields = [
367
+ [ 'Brave' , app . getVersion ] ,
368
+ [ 'rev' , Channel . browserLaptopRev ] ,
369
+ [ 'Muon' , ( ) => { return process . versions [ 'atom-shell' ] } ] ,
370
+ [ 'libchromiumcontent' , ( ) => { return process . versions [ 'chrome' ] } ] ,
371
+ [ 'V8' , ( ) => { return process . versions . v8 } ] ,
372
+ [ 'Node.js' , ( ) => { return process . versions . node } ] ,
373
+ [ 'Update Channel' , Channel . channel ] ,
374
+ [ 'os.platform' , require ( 'os' ) . platform ] ,
375
+ [ 'os.release' , require ( 'os' ) . release ] ,
376
+ [ 'os.arch' , require ( 'os' ) . arch ]
377
+ ]
378
+ const versionInformation = [ ]
379
+
380
+ versionFields . forEach ( ( field ) => {
381
+ versionInformation . push ( safeGetVersion ( field [ 0 ] , field [ 1 ] ) )
382
+ } )
383
+
384
+ data . about = data . about || { }
385
+ data . about . brave = {
386
+ versionInformation : versionInformation
369
387
}
370
388
return data
371
389
}
0 commit comments