From a864e357ff1d94fe938c25bce9affbc7bcfc2b8d Mon Sep 17 00:00:00 2001 From: ALiangLiang Date: Sun, 13 Nov 2016 22:17:13 +0800 Subject: [PATCH] Fix auto update --- .travis.yml | 7 ------- app/main.js | 7 ++++--- app/package.json | 2 +- appveyor.yml | 7 +------ release.js | 20 ++++++++++++++++++++ 5 files changed, 26 insertions(+), 17 deletions(-) create mode 100644 release.js diff --git a/.travis.yml b/.travis.yml index 4b34d6a..2d9bedd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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: diff --git a/app/main.js b/app/main.js index 5c3086f..fc95ef9 100644 --- a/app/main.js +++ b/app/main.js @@ -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(); @@ -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*/ ); }); }); }); diff --git a/app/package.json b/app/package.json index 7cb7694..149ae07 100644 --- a/app/package.json +++ b/app/package.json @@ -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", diff --git a/appveyor.yml b/appveyor.yml index 8f0aa76..f9c52d3 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -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 @@ -28,6 +22,7 @@ build_script: - node --version - npm --version - npm run dist + - node release.js test: off diff --git a/release.js b/release.js new file mode 100644 index 0000000..d6575d1 --- /dev/null +++ b/release.js @@ -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)); + }) +});