Skip to content

Commit 38c269d

Browse files
committed
minor refactor
1 parent 541589a commit 38c269d

File tree

2 files changed

+6
-26
lines changed

2 files changed

+6
-26
lines changed

dist/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main.ts

Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { setFailed, info, debug, addPath, getInput } from "@actions/core";
1+
import { setFailed, info, addPath, getInput } from "@actions/core";
22
import * as exec from "@actions/exec";
33
import * as tc from "@actions/tool-cache";
44
import * as http from "@actions/http-client";
@@ -7,13 +7,7 @@ import * as os from "os";
77
const TOOL = "fastly-cli";
88

99
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));
1711

1812
addPath(toolPath);
1913
}
@@ -33,27 +27,13 @@ async function download(version: string, osPlat: string): Promise<string> {
3327
? tc.extractZip(downloadPath)
3428
: tc.extractTar(downloadPath);
3529

36-
console.log(`Downloading and extracting ${url}`);
30+
info(`Downloading and extracting ${url}`);
3731
return await tc.cacheDir(await extPath, TOOL, version);
3832
}
3933

4034
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";
5737

5838
return `fastly_${version}_${platform}-amd64.${ext}`;
5939
}

0 commit comments

Comments
 (0)