-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.js
56 lines (51 loc) · 1.32 KB
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
var http = require('http');
var fs = require('fs');
const { app, BrowserWindow, Menu } = require('electron')
const path = require('path')
function createWindow () {
const win = new BrowserWindow({
width: 320,
height: 480,
frame: false,
resizable: false,
icon: "./strike.ico"
})
win.loadFile('index.html')
}
app.setUserTasks([
{
program: null,
arguments: '',
iconPath: process.execPath,
iconIndex: 0,
title: 'Check For Updates',
description: 'Checks for app updates'
}
])
app.whenReady().then(() => {
Menu.setApplicationMenu(null)
createWindow()
})
app.on('window-all-closed', function () {
if (process.platform !== 'darwin') app.quit()
})
function pDownload(url, dest){
var file = fs.createWriteStream(dest);
return new Promise((resolve, reject) => {
var responseSent = false; // flag to make sure that response is sent only once.
http.get(url, response => {
response.pipe(file);
file.on('finish', () =>{
file.close(() => {
if(responseSent) return;
responseSent = true;
resolve();
});
});
}).on('error', err => {
if(responseSent) return;
responseSent = true;
reject(err);
});
});
}