Merge pull request #561 from yuya-oc/fix-windows-uninstaller

Fix Windows uninstaller not removing files correctly
This commit is contained in:
Yuya Ochiai 2017-07-12 22:45:56 +09:00 committed by GitHub
commit aad60e2d16
4 changed files with 46 additions and 30 deletions

View file

@ -1,7 +1,9 @@
{ {
"extends": "./.eslintrc-platform.json", "extends": "./.eslintrc-platform.json",
"parserOptions": {
"ecmaVersion": 2017
},
"rules": { "rules": {
"global-require": 1,
"indent": [2, 2, {"SwitchCase": 0}], "indent": [2, 2, {"SwitchCase": 0}],
"no-console": 0, "no-console": 0,
"no-eval": 1, "no-eval": 1,

View file

@ -31,6 +31,8 @@ Release date: TBD
#### Windows #### Windows
- Fixed desktop notifications not working when the window has been minimized from inactive state. - Fixed desktop notifications not working when the window has been minimized from inactive state.
[#522](https://github.com/mattermost/desktop/issues/522) [#522](https://github.com/mattermost/desktop/issues/522)
- Fixed the uninstaller not removing files correctly.
[#551](https://github.com/mattermost/desktop/issues/551)
#### Mac #### Mac
- Fixed an issue where the text box didn't keep focus after uploading a file. - Fixed an issue where the text box didn't keep focus after uploading a file.

View file

@ -12,8 +12,7 @@ const {
} = require('electron'); } = require('electron');
const isDev = require('electron-is-dev'); const isDev = require('electron-is-dev');
const installExtension = require('electron-devtools-installer'); const installExtension = require('electron-devtools-installer');
const squirrelStartup = require('./main/squirrelStartup');
const AutoLaunch = require('auto-launch');
process.on('uncaughtException', (error) => { process.on('uncaughtException', (error) => {
console.error(error); console.error(error);
@ -21,34 +20,8 @@ process.on('uncaughtException', (error) => {
global.willAppQuit = false; global.willAppQuit = false;
if (process.platform === 'win32') {
var cmd = process.argv[1];
var appLauncher = new AutoLaunch({
name: 'Mattermost',
isHidden: true
});
if (cmd === '--squirrel-uninstall') {
// If we're uninstalling, make sure we also delete our auto launch registry key
appLauncher.isEnabled().then((enabled) => {
if (enabled) {
appLauncher.disable();
}
});
} else if (cmd === '--squirrel-install' || cmd === '--squirrel-updated') {
// If we're updating and already have an registry entry for auto launch, make sure to update the path
appLauncher.isEnabled().then((enabled) => {
if (enabled) {
return appLauncher.disable().then(() => {
return appLauncher.enable();
});
}
return true;
});
}
}
app.setAppUserModelId('com.squirrel.mattermost.Mattermost'); // Use explicit AppUserModelID app.setAppUserModelId('com.squirrel.mattermost.Mattermost'); // Use explicit AppUserModelID
if (require('electron-squirrel-startup')) { if (squirrelStartup()) {
global.willAppQuit = true; global.willAppQuit = true;
} }

View file

@ -0,0 +1,39 @@
const AutoLaunch = require('auto-launch');
function shouldQuitApp(cmd) {
if (process.platform !== 'win32') {
return false;
}
return ['--squirrel-install', '--squirrel-updated', '--squirrel-uninstall', '--squirrel-obsolete'].includes(cmd);
}
async function setupAutoLaunch(cmd) {
const appLauncher = new AutoLaunch({
name: 'Mattermost',
isHidden: true
});
if (cmd === '--squirrel-uninstall') {
// If we're uninstalling, make sure we also delete our auto launch registry key
return appLauncher.disable();
} else if (cmd === '--squirrel-install' || cmd === '--squirrel-updated') {
// If we're updating and already have an registry entry for auto launch, make sure to update the path
const enabled = await appLauncher.isEnabled();
if (enabled) {
return appLauncher.enable();
}
}
return async () => true;
}
function squirrelStartup() {
if (process.platform === 'win32') {
const cmd = process.argv[1];
setupAutoLaunch(cmd).then(() => {
require('electron-squirrel-startup'); // eslint-disable-line global-require
});
return shouldQuitApp(cmd);
}
return false;
}
module.exports = squirrelStartup;