@@ -17,7 +17,6 @@ limitations under the License.
1717import path from "path" ;
1818import { spawn } from "child_process" ;
1919import { app } from "electron" ;
20- import { promises as fsProm } from "fs" ;
2120
2221function runUpdateExe ( args : string [ ] ) : Promise < void > {
2322 // Invokes Squirrel's Update.exe which will do things for us like create shortcuts
@@ -35,44 +34,16 @@ function runUpdateExe(args: string[]): Promise<void> {
3534
3635function checkSquirrelHooks ( ) : boolean {
3736 if ( process . platform !== 'win32' ) return false ;
38-
3937 const cmd = process . argv [ 1 ] ;
4038 const target = path . basename ( process . execPath ) ;
41- if ( cmd === '--squirrel-install' || cmd === '--squirrel-updated' ) {
42- runUpdateExe ( [ '--createShortcut=' + target ] ) . then ( ( ) => {
43- // remove the old 'Riot' shortcuts, if they exist (update.exe --removeShortcut doesn't work
44- // because it always uses the name of the product as the name of the shortcut: the only variable
45- // is what executable you're linking to)
46- const appDataDir = process . env . APPDATA ;
47- if ( ! appDataDir ) return ;
48- const startMenuDir = path . join (
49- appDataDir , 'Microsoft' , 'Windows' , 'Start Menu' , 'Programs' , 'New Vector Ltd' ,
50- ) ;
51- return fsProm . rmdir ( startMenuDir , { recursive : true } ) ;
52- } ) . then ( ( ) => {
53- // same for 'Element (Riot) which is old now too (we have to try to delete both because
54- // we don't know what version we're updating from, but of course we do know this version
55- // is 'Element' so the two old ones are all safe to delete).
56- const appDataDir = process . env . APPDATA ;
57- if ( ! appDataDir ) return ;
58- const oldStartMenuLink = path . join (
59- appDataDir , 'Microsoft' , 'Windows' , 'Start Menu' , 'Programs' , 'Element' , 'Element (Riot).lnk' ,
60- ) ;
61- return fsProm . unlink ( oldStartMenuLink ) . catch ( ( ) => { } ) ;
62- } ) . then ( ( ) => {
63- const oldDesktopShortcut = path . join ( app . getPath ( 'desktop' ) , 'Element (Riot).lnk' ) ;
64- return fsProm . unlink ( oldDesktopShortcut ) . catch ( ( ) => { } ) ;
65- } ) . then ( ( ) => {
66- const oldDesktopShortcut = path . join ( app . getPath ( 'desktop' ) , 'Riot.lnk' ) ;
67- return fsProm . unlink ( oldDesktopShortcut ) . catch ( ( ) => { } ) ;
68- } ) . then ( ( ) => {
69- app . quit ( ) ;
70- } ) ;
39+ if ( cmd === '--squirrel-install' ) {
40+ runUpdateExe ( [ '--createShortcut=' + target ] ) . then ( ( ) => app . quit ( ) ) ;
41+ return true ;
42+ } else if ( cmd === '--squirrel-updated' ) {
43+ app . quit ( ) ;
7144 return true ;
7245 } else if ( cmd === '--squirrel-uninstall' ) {
73- runUpdateExe ( [ '--removeShortcut=' + target ] ) . then ( ( ) => {
74- app . quit ( ) ;
75- } ) ;
46+ runUpdateExe ( [ '--removeShortcut=' + target ] ) . then ( ( ) => app . quit ( ) ) ;
7647 return true ;
7748 } else if ( cmd === '--squirrel-obsolete' ) {
7849 app . quit ( ) ;
0 commit comments