This repository was archived by the owner on Jan 14, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 5 files changed +58
-0
lines changed
Expand file tree Collapse file tree 5 files changed +58
-0
lines changed Original file line number Diff line number Diff line change 11const electron = require ( 'electron' )
2+ const os = require ( 'os' )
23const BrowserWindow = electron . BrowserWindow
34const dialog = electron . dialog
45
6+ function getAppInfo ( ) {
7+ const info = `
8+ Version: ${ process . getVersion ( ) }
9+ Commit: ${ process . getCommit ( ) }
10+ Electron: ${ process . versions . electron }
11+ Chrome: ${ process . versions . chrome }
12+ Node.js: ${ process . versions . node }
13+ V8: ${ process . versions . v8 }
14+ OS: ${ os . type ( ) } ${ os . arch ( ) } ${ os . release ( ) } `
15+ return info
16+ }
17+
518function getMenu ( app , mainWindow ) {
619 const macOS = process . platform === 'darwin'
720
@@ -99,6 +112,18 @@ function getMenu (app, mainWindow) {
99112 click ( ) {
100113 BrowserWindow . getFocusedWindow ( ) . reload ( )
101114 }
115+ } ,
116+ {
117+ label : 'About' ,
118+ click ( ) {
119+ dialog . showMessageBox ( {
120+ type : 'info' ,
121+ title : 'Snippet Store' ,
122+ message : 'Snippet Store' ,
123+ detail : getAppInfo ( ) ,
124+ buttons : [ 'OK' ]
125+ } )
126+ }
102127 }
103128 ]
104129 }
Original file line number Diff line number Diff line change 11function runMainApp ( ) {
22 require ( './app/app-main' )
33}
4+
5+ process . getCommit = ( ) => {
6+ if ( process . env . npm_package_gitHead ) return process . env . npm_package_gitHead
7+ return require ( './product.json' ) . commit
8+ }
9+
10+ process . getVersion = ( ) => {
11+ if ( process . env . npm_package_version ) return process . env . npm_package_version
12+ return require ( './product.json' ) . version
13+ }
14+
415runMainApp ( )
Original file line number Diff line number Diff line change 88 "fix" : " eslint . --fix" ,
99 "lint" : " eslint ." ,
1010 "build" : " node scripts/build.js" ,
11+ "product" : " node scripts/product.js" ,
1112 "dist:linux" : " npm run build && rimraf dist/ && electron-builder --linux" ,
1213 "dist:win" : " npm run build && rimraf dist/ && electron-builder --win" ,
1314 "dist:mac" : " npm run build && rimraf dist/ && electron-builder --mac" ,
2829 },
2930 "files" : [
3031 " index.js" ,
32+ " product.json" ,
3133 " compiled/**/*" ,
3234 " app/**/*" ,
3335 " resources/**/*" ,
Original file line number Diff line number Diff line change 1+ {"version" :" 0.2.10" ,"commit" :" f965b4e453682a27162685d9415f86999116bef5" }
Original file line number Diff line number Diff line change 1+ const fs = require ( 'fs' )
2+ const path = require ( 'path' )
3+
4+ const pkgPath = path . join ( __dirname , '../package.json' )
5+ const productPath = path . join ( __dirname , '../product.json' )
6+ const pkg = require ( pkgPath )
7+
8+ function generateProductInfo ( ) {
9+ const product = {
10+ version : pkg . version ,
11+ commit : require ( 'child_process' )
12+ . execSync ( 'git rev-parse HEAD' )
13+ . toString ( )
14+ . trim ( )
15+ }
16+ fs . writeFileSync ( productPath , JSON . stringify ( product ) )
17+ }
18+
19+ generateProductInfo ( )
You can’t perform that action at this time.
0 commit comments