Skip to content

Commit

Permalink
Fix auto update
Browse files Browse the repository at this point in the history
  • Loading branch information
ALiangLiang committed Nov 13, 2016
1 parent 1d43474 commit a864e35
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 17 deletions.
7 changes: 0 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,6 @@ install:
- npm install
- build --version

cache:
directories:
- node_modules
- app\node_modules
- "%APPDATA%\\npm-cache"
- "%USERPROFILE%\\.electron"

deploy:
provider: releases
api_key:
Expand Down
7 changes: 4 additions & 3 deletions app/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,16 @@ function initUpdates() {

autoUpdater.on('update-available', () => {
console.log('update-available');
autoUpdater.quitAndInstall();

});

autoUpdater.on('update-not-available', () => {
console.log('update-not-available');
});

autoUpdater.on('update-downloaded', () => {
autoUpdater.on('update-downloaded', (a, b, c, d, e, quitAndInstall) => {
console.log('update-downloaded');
quitAndInstall();
});

autoUpdater.checkForUpdates();
Expand Down Expand Up @@ -114,7 +115,7 @@ Promise.all([genUA(), readyPromise])
visitor.event('login', 'failed').send();
const noti = notify((status.isSuccess) ? globalValue.STRING_LOGIN_SUCCESS : globalValue.STRING_LOGIN_FAILED, {
body: status.message
}, openSettingPage, app.quit);
}, openSettingPage /*, app.quit*/ );
});
});
});
2 changes: 1 addition & 1 deletion app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tanetroamer-desktop",
"productName": "TANet Roamer 校園網路漫遊器",
"productName": "TANet-Roamer",
"version": "0.0.2",
"description": "一鍵登入校園 WI-FI 的桌面應用程式",
"homepage": "https://github.com/ALiangLiang/tanetroamer-desktop",
Expand Down
7 changes: 1 addition & 6 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,6 @@ environment:
platform:
- x64

cache:
- node_modules
- app\node_modules
- '%APPDATA%\npm-cache'
- '%USERPROFILE%\.electron'

init:
- git config --global core.autocrlf input

Expand All @@ -28,6 +22,7 @@ build_script:
- node --version
- npm --version
- npm run dist
- node release.js

test: off

Expand Down
20 changes: 20 additions & 0 deletions release.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const fs = require('fs');

function changeName(name) {
return name.replace(/ /g, '.').replace(/[\W]/g, '.').replace(/\.+/g, '.')
}

const base = 'dist/';
fs.readFile(base + 'latest.yml', {
encoding: 'utf8'
}, (err, data) => {
const
raw = data.split('\n'),
originName = raw[1].replace('path: ', ''),
newName = changeName(originName);
fs.rename(base + originName, base + newName, () => {
raw[1] = 'path: ' + newName;
const content = raw.join('\n');
fs.writeFile(base + 'latest.yml', content, () => console.log(content));
})
});

0 comments on commit a864e35

Please sign in to comment.