@@ -8,41 +8,49 @@ import type { InstallSpec, Installer } from "./installers";
88import { LatestVersion } from "./versions" ;
99
1010export class MacOSInstaller implements Installer {
11- async install ( spec : InstallSpec ) : Promise < string > {
12- const installPath = await this . download ( spec ) ;
13- return path . join ( installPath , "Contents" , "MacOS" ) ;
14- }
15-
16- async download ( {
17- version,
18- platform,
19- language,
20- } : InstallSpec ) : Promise < string > {
11+ async install ( { version, platform, language } : InstallSpec ) : Promise < string > {
2112 const toolPath = tc . find ( "firefox" , version ) ;
2213 if ( toolPath ) {
2314 core . info ( `Found in cache @ ${ toolPath } ` ) ;
2415 return toolPath ;
2516 }
2617 core . info ( `Attempting to download firefox ${ version } ...` ) ;
18+ const archivePath = await this . downloadArchive ( {
19+ version,
20+ platform,
21+ language,
22+ } ) ;
23+
24+ core . info ( "Extracting Firefox..." ) ;
25+ const appPath = await this . extractArchive ( archivePath , version ) ;
26+ core . info ( `Successfully extracted firefox ${ version } to ${ appPath } ` ) ;
27+
28+ core . info ( "Adding to the cache ..." ) ;
29+ const cachedDir = await tc . cacheDir ( appPath , "firefox" , version ) ;
30+ core . info ( `Successfully cached firefox ${ version } to ${ cachedDir } ` ) ;
2731
32+ return path . join ( cachedDir , "Contents" , "MacOS" ) ;
33+ }
34+
35+ private async downloadArchive ( {
36+ version,
37+ platform,
38+ language,
39+ } : InstallSpec ) : Promise < string > {
2840 const url = new DownloadURLFactory ( version , platform , language )
2941 . create ( )
3042 . getURL ( ) ;
3143 core . info ( `Acquiring ${ version } from ${ url } ` ) ;
3244
3345 const archivePath = await tc . downloadTool ( url ) ;
34- core . info ( "Extracting Firefox..." ) ;
46+ return archivePath ;
47+ }
3548
49+ private async extractArchive (
50+ archivePath : string ,
51+ version : string ,
52+ ) : Promise < string > {
3653 const mountpoint = path . join ( "/Volumes" , path . basename ( archivePath ) ) ;
37- const appPath = ( ( ) => {
38- if ( version === LatestVersion . LATEST_NIGHTLY ) {
39- return path . join ( mountpoint , "Firefox Nightly.app" ) ;
40- } else if ( version . includes ( "devedition" ) ) {
41- return path . join ( mountpoint , "Firefox Developer Edition.app" ) ;
42- } else {
43- return path . join ( mountpoint , "Firefox.app" ) ;
44- }
45- } ) ( ) ;
4654
4755 await exec . exec ( "hdiutil" , [
4856 "attach" ,
@@ -53,12 +61,14 @@ export class MacOSInstaller implements Installer {
5361 mountpoint ,
5462 archivePath ,
5563 ] ) ;
56- core . info ( `Successfully extracted firefox ${ version } to ${ appPath } ` ) ;
5764
58- core . info ( "Adding to the cache ..." ) ;
59- const cachedDir = await tc . cacheDir ( appPath , "firefox" , version ) ;
60- core . info ( `Successfully cached firefox ${ version } to ${ cachedDir } ` ) ;
61- return cachedDir ;
65+ if ( version === LatestVersion . LATEST_NIGHTLY ) {
66+ return path . join ( mountpoint , "Firefox Nightly.app" ) ;
67+ } else if ( version . includes ( "devedition" ) ) {
68+ return path . join ( mountpoint , "Firefox Developer Edition.app" ) ;
69+ } else {
70+ return path . join ( mountpoint , "Firefox.app" ) ;
71+ }
6272 }
6373
6474 async testVersion ( bin : string ) : Promise < string > {
0 commit comments