@@ -13,6 +13,10 @@ const name = app.getName();
13
13
var updateFeed = 'http://localhost:3000/updates/latest' ;
14
14
var isDevelopment = process . env . NODE_ENV === 'development' ;
15
15
var feedURL = '' ;
16
+ const logger = require ( 'winston' ) ;
17
+ logger . level = 'debug' ;
18
+ global . logger = logger ;
19
+ const path = require ( 'path' ) ;
16
20
17
21
// Don't use auto-updater if we are in development
18
22
if ( ! isDevelopment ) {
@@ -23,31 +27,31 @@ if (!isDevelopment) {
23
27
}
24
28
25
29
autoUpdater . addListener ( 'update-available' , function ( event ) {
26
- console . log ( 'A new update is available' ) ;
30
+ logger . log ( 'A new update is available' ) ;
27
31
if ( mainWindow ) {
28
32
mainWindow . webContents . send ( 'update-message' , 'update-available' ) ;
29
33
}
30
34
} ) ;
31
- autoUpdater . addListener ( " update-downloaded" , function ( event , releaseNotes , releaseName , releaseDate , updateURL ) {
32
- console . log ( 'A new update is ready to install' , `Version ${ releaseName } is downloaded and will be automatically installed on Quit` )
35
+ autoUpdater . addListener ( ' update-downloaded' , function ( event , releaseNotes , releaseName , releaseDate , updateURL ) {
36
+ logger . log ( 'A new update is ready to install' , `Version ${ releaseName } is downloaded and will be automatically installed on Quit` )
33
37
if ( mainWindow ) {
34
38
mainWindow . webContents . send ( 'update-message' , 'update-downloaded' ) ;
35
39
}
36
40
} ) ;
37
41
autoUpdater . addListener ( 'error' , function ( error ) {
38
- console . log ( error ) ;
42
+ logger . log ( error ) ;
39
43
if ( mainWindow ) {
40
44
mainWindow . webContents . send ( 'update-message' , 'update-error' ) ;
41
45
}
42
46
} ) ;
43
47
autoUpdater . addListener ( 'checking-for-update' , function ( event ) {
44
- console . log ( 'checking-for-update' ) ;
48
+ logger . log ( 'checking-for-update' ) ;
45
49
if ( mainWindow ) {
46
50
mainWindow . webContents . send ( 'update-message' , 'checking-for-update' ) ;
47
51
}
48
52
} ) ;
49
53
autoUpdater . addListener ( "update-not-available" , function ( ) {
50
- console . log ( 'update-not-available' ) ;
54
+ logger . log ( 'update-not-available' ) ;
51
55
if ( mainWindow ) {
52
56
mainWindow . webContents . send ( 'update-message' , 'update-not-available' ) ;
53
57
}
@@ -181,37 +185,45 @@ app.on('ready', function() {
181
185
182
186
const menu = Menu . buildFromTemplate ( template ) ;
183
187
188
+ logger . debug ( 'Starting application' ) ;
189
+
184
190
Menu . setApplicationMenu ( menu ) ;
185
191
mainWindow = new BrowserWindow ( {
192
+ name : 'Binary.com' ,
186
193
width : 1024 ,
187
194
height : 680 ,
195
+ toolbar : false ,
188
196
} ) ;
189
197
190
- mainWindow . loadURL ( 'file://' + __dirname + '/index.html' ) ;
198
+ mainWindow . loadURL ( path . join ( 'file://' , __dirname , '/index.html' ) ) ;
191
199
192
200
mainWindow . on ( 'closed' , function ( ) {
193
201
console . log ( 'closed' ) ;
194
202
mainWindow = null ;
195
203
app . quit ( ) ;
196
204
} ) ;
197
205
206
+ // Uncomment to use Chrome developer tools
207
+ mainWindow . webContents . openDevTools ( { detach :true } ) ;
208
+
198
209
mainWindow . on ( 'close' , function ( e ) {
199
210
if ( ! forceQuit ) {
200
211
e . preventDefault ( ) ;
201
212
mainWindow . hide ( ) ;
213
+ } else {
214
+ app . quit ( ) ;
202
215
}
203
216
} ) ;
204
217
app . on ( 'activate' , function ( ) {
205
218
mainWindow . show ( ) ;
206
219
} ) ;
207
220
208
221
mainWindow . on ( 'show' , function ( e ) {
209
- console . log ( 'the window is showing' ) ;
210
222
mainWindow . show ( ) ;
211
223
} ) ;
212
224
213
225
mainWindow . on ( 'hide' , function ( e ) {
214
- console . log ( 'the main window is hiding' ) ;
226
+ mainWindow . hide ( ) ;
215
227
} ) ;
216
228
} ) ;
217
229
0 commit comments