-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathauto-update-stub.js
More file actions
37 lines (31 loc) · 646 Bytes
/
Copy pathauto-update-stub.js
File metadata and controls
37 lines (31 loc) · 646 Bytes
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
const EventEmitter = require('events');
class AutoUpdateStub extends EventEmitter {
constructor(options = {}) {
super();
this.options = {
downloadAvailableIn: 0,
onQuit: () => {},
...options
};
if (this.options.downloadAvailableIn === 0) {
this.downloadAvailable = true;
} else {
setTimeout(() => {
this.downloadAvailable = true;
}, this.options.downloadAvailableIn);
}
}
checkForUpdates() {
if (this.downloadAvailable) {
this.emit('update-downloaded');
} else {
this.emit('update-not-available');
}
}
quitAndInstall() {
this.options.onQuit();
}
}
module.exports = {
AutoUpdateStub
};