Skip to content

Commit 19b052b

Browse files
committed
Fixed Updater
1 parent 2008e43 commit 19b052b

File tree

2 files changed

+15
-14
lines changed

2 files changed

+15
-14
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "simplelauncher",
3-
"version": "0.3.1",
3+
"version": "0.3.2",
44
"description": "Launcher for SimpleClient",
55
"main": "src/main.js",
66
"scripts": {

src/updater.js

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -36,20 +36,21 @@ const checkForUpdates = async () => {
3636
}
3737

3838
if (!isMainThread) {
39-
const response = await fetch(`https://api.github.com/repos/${repository}/releases/latest`)
40-
if (response && response.ok) {
41-
const json = await response.json()
42-
const dir = join(getDirectory(), 'updates')
43-
if (!existsSync(dir)) mkdirSync(dir, {recursive: true})
44-
if (platform() == 'win32') {
45-
log('Downloading update...')
46-
spawnSync('curl', ['-L', json.assets[0].browser_download_url, '-o', join(dir, json.assets[0].name)])
47-
log('Successfully downloaded update')
48-
log('Installing update...')
49-
execFile(join(dir, json.assets[0].name), {shell: true}).unref()
50-
exit(0)
39+
const response = fetch(`https://api.github.com/repos/${repository}/releases/latest`).then(async response => {
40+
if (response && response.ok) {
41+
const json = await response.json()
42+
const dir = join(getDirectory(), 'updates')
43+
if (!existsSync(dir)) mkdirSync(dir, {recursive: true})
44+
if (platform() == 'win32') {
45+
log('Downloading update...')
46+
spawnSync('curl', ['-L', json.assets[0].browser_download_url, '-o', join(dir, json.assets[0].name)])
47+
log('Successfully downloaded update')
48+
log('Installing update...')
49+
execFile(join(dir, json.assets[0].name), {shell: true}).unref()
50+
exit(0)
51+
}
5152
}
52-
} else return undefined
53+
})
5354
}
5455

5556
const update = async () => new Worker(resolve(join(__dirname, 'updater.js')))

0 commit comments

Comments
 (0)