1
- import { setFailed , info , debug , addPath , getInput } from "@actions/core" ;
1
+ import { setFailed , info , addPath , getInput } from "@actions/core" ;
2
2
import * as exec from "@actions/exec" ;
3
3
import * as tc from "@actions/tool-cache" ;
4
4
import * as http from "@actions/http-client" ;
@@ -7,13 +7,7 @@ import * as os from "os";
7
7
const TOOL = "fastly-cli" ;
8
8
9
9
export async function install ( version : string , osPlat : string ) {
10
- console . log ( `version ${ version } ` ) ;
11
- let toolPath = tc . find ( TOOL , version ) ;
12
-
13
- if ( ! toolPath ) {
14
- toolPath = await download ( version , osPlat ) ;
15
- debug ( `Fastly cli cached under ${ toolPath } ` ) ;
16
- }
10
+ const toolPath = tc . find ( TOOL , version ) || ( await download ( version , osPlat ) ) ;
17
11
18
12
addPath ( toolPath ) ;
19
13
}
@@ -33,27 +27,13 @@ async function download(version: string, osPlat: string): Promise<string> {
33
27
? tc . extractZip ( downloadPath )
34
28
: tc . extractTar ( downloadPath ) ;
35
29
36
- console . log ( `Downloading and extracting ${ url } ` ) ;
30
+ info ( `Downloading and extracting ${ url } ` ) ;
37
31
return await tc . cacheDir ( await extPath , TOOL , version ) ;
38
32
}
39
33
40
34
export function fileName ( version : string , osPlat : string ) : string {
41
- let platform = "" ;
42
- let ext = "" ;
43
- switch ( osPlat ) {
44
- case "win32" :
45
- platform = "windows" ;
46
- ext = "zip" ;
47
- break ;
48
- case "linux" :
49
- platform = "linux" ;
50
- ext = "tar.gz" ;
51
- break ;
52
- case "darwin" :
53
- platform = "darwin" ;
54
- ext = "tar.gz" ;
55
- break ;
56
- }
35
+ const platform = osPlat === "win32" ? "windows" : osPlat ;
36
+ const ext = osPlat === "win32" ? "zip" : "tar.gz" ;
57
37
58
38
return `fastly_${ version } _${ platform } -amd64.${ ext } ` ;
59
39
}
0 commit comments