@@ -17,7 +17,7 @@ import {
17
17
WorkspaceFolder ,
18
18
} from 'vscode' ;
19
19
import { Logger } from 'vscode-languageclient' ;
20
- import { downloadFile , executableExists , httpsGetSilently , resolvePathPlaceHolders } from './utils' ;
20
+ import { executableExists , httpsGetSilently , resolvePathPlaceHolders } from './utils' ;
21
21
22
22
export type ReleaseMetadata = Map < string , Map < string , Map < string , string [ ] > > > ;
23
23
@@ -461,57 +461,15 @@ export async function getProjectGHCVersion(toolchainBindir: string, workingDir:
461
461
export async function getGHCup ( context : ExtensionContext , logger : Logger ) : Promise < string | undefined > {
462
462
logger . info ( 'Checking for ghcup installation' ) ;
463
463
const localGHCup = [ 'ghcup' ] . find ( executableExists ) ;
464
+ if ( ! localGHCup ) {
465
+ throw new MissingToolError ( 'ghcup' ) ;
466
+ }
464
467
465
- if ( manageHLS === 'system-ghcup' ) {
466
- if ( ! localGHCup ) {
467
- throw new MissingToolError ( 'ghcup' ) ;
468
- } else {
469
- logger . info ( `found system ghcup at ${ localGHCup } ` ) ;
470
- const args = [ 'upgrade' ] ;
471
- await callGHCup ( context , logger , args , 'Upgrading ghcup' , true ) ;
472
- return localGHCup ;
473
- }
474
- } else if ( manageHLS === 'internal-ghcup' ) {
475
- const storagePath : string = await getStoragePath ( context ) ;
476
- let ghcup = path . join ( storagePath , `ghcup${ exeExt } ` ) ;
477
- if ( ! fs . existsSync ( storagePath ) ) {
478
- fs . mkdirSync ( storagePath ) ;
479
- }
480
-
481
- // ghcup exists, just upgrade
482
- if ( fs . existsSync ( ghcup ) ) {
483
- logger . info ( 'ghcup already installed, trying to upgrade' ) ;
484
- const args = [ 'upgrade' , '-i' ] ;
485
- await callGHCup ( context , logger , args , 'Upgrading ghcup' , true ) ;
486
- } else {
487
- // needs to download ghcup
488
- const plat = match ( process . platform )
489
- . with ( 'darwin' , ( _ ) => 'apple-darwin' )
490
- . with ( 'linux' , ( _ ) => 'linux' )
491
- . with ( 'win32' , ( _ ) => 'mingw64' )
492
- . with ( 'freebsd' , ( _ ) => 'freebsd12' )
493
- . otherwise ( ( _ ) => null ) ;
494
- if ( plat === null ) {
495
- throw new Error ( `Couldn't find any pre-built ghcup binary for ${ process . platform } ` ) ;
496
- }
497
- const arch = match ( process . arch )
498
- . with ( 'arm' , ( _ ) => 'armv7' )
499
- . with ( 'arm64' , ( _ ) => 'aarch64' )
500
- . with ( 'x32' , ( _ ) => 'i386' )
501
- . with ( 'x64' , ( _ ) => 'x86_64' )
502
- . otherwise ( ( _ ) => null ) ;
503
- if ( arch === null ) {
504
- throw new Error ( `Couldn't find any pre-built ghcup binary for ${ process . arch } ` ) ;
505
- }
506
- const dlUri = `https://downloads.haskell.org/~ghcup/${ arch } -${ plat } -ghcup${ exeExt } ` ;
507
- const title = `Downloading ${ dlUri } ` ;
508
- logger . info ( `Downloading ${ dlUri } ` ) ;
509
- const downloaded = await downloadFile ( title , dlUri , ghcup ) ;
510
- if ( ! downloaded ) {
511
- throw new Error ( `Couldn't download ${ dlUri } as ${ ghcup } ` ) ;
512
- }
513
- }
514
- return ghcup ;
468
+ if ( manageHLS === 'system-ghcup' || manageHLS == 'internal-ghcup' ) {
469
+ logger . info ( `found ghcup at ${ localGHCup } ` ) ;
470
+ const args = [ 'upgrade' ] ;
471
+ await callGHCup ( context , logger , args , 'Upgrading ghcup' , true ) ;
472
+ return localGHCup ;
515
473
} else {
516
474
throw new Error ( `Internal error: tried to call ghcup while haskell.manageHLS is set to ${ manageHLS } . Aborting!` ) ;
517
475
}
0 commit comments