From cfc658b90a3f84f9dfc3a3ce1b462daba9c50db2 Mon Sep 17 00:00:00 2001 From: Bryan MacFarlane Date: Sun, 9 Feb 2020 08:47:38 -0500 Subject: [PATCH] format --- lib/installer.js | 86 ------------------------------------------------ lib/setup-go.js | 4 --- src/main.ts | 2 +- 3 files changed, 1 insertion(+), 91 deletions(-) delete mode 100644 lib/installer.js delete mode 100644 lib/setup-go.js diff --git a/lib/installer.js b/lib/installer.js deleted file mode 100644 index 5688337..0000000 --- a/lib/installer.js +++ /dev/null @@ -1,86 +0,0 @@ -"use strict"; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; - result["default"] = mod; - return result; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const tc = __importStar(require("@actions/tool-cache")); -const path = __importStar(require("path")); -const semver = __importStar(require("semver")); -const httpm = __importStar(require("@actions/http-client")); -const sys = __importStar(require("./system")); -function downloadGo(versionSpec, stable) { - return __awaiter(this, void 0, void 0, function* () { - let toolPath; - try { - let match = yield findMatch(versionSpec, stable); - if (match) { - // download - let downloadUrl = `https://storage.googleapis.com/golang/${match.files[0].filename}`; - let downloadPath = yield tc.downloadTool(downloadUrl); - // extract - let extPath = sys.getPlatform() == 'windows' - ? yield tc.extractZip(downloadPath) - : yield tc.extractTar(downloadPath); - // extracts with a root folder that matches the fileName downloaded - const toolRoot = path.join(extPath, 'go'); - toolPath = yield tc.cacheDir(toolRoot, 'go', versionSpec); - } - } - catch (error) { - throw `Failed to download version ${versionSpec}: ${error}`; - } - return toolPath; - }); -} -exports.downloadGo = downloadGo; -function findMatch(versionSpec, stable) { - return __awaiter(this, void 0, void 0, function* () { - let archFilter = sys.getArch(); - let platFilter = sys.getPlatform(); - let match; - const dlUrl = 'https://golang.org/dl/?mode=json&include=all'; - // this returns versions descending so latest is first - let http = new httpm.HttpClient('setup-go'); - let candidates = (yield http.getJson(dlUrl)).result; - if (!candidates) { - throw new Error(`golang download url did not return results: ${dlUrl}`); - } - let goFile; - for (let i = 0; i < candidates.length; i++) { - let candidate = candidates[i]; - let version = candidate.version.replace('go', ''); - // 1.13.0 is advertised as 1.13 preventing being able to match exactly 1.13.0 - // since a semver of 1.13 would match latest 1.13 - let parts = version.split('.'); - if (parts.length == 2) { - version = version + '.0'; - } - if (semver.satisfies(version, versionSpec) && candidate.stable == stable) { - goFile = candidate.files.find(file => { - return file.arch === archFilter && file.os === platFilter; - }); - if (goFile) { - match = candidate; - break; - } - } - } - if (match && goFile) { - match.files = [goFile]; - } - return match; - }); -} -exports.findMatch = findMatch; diff --git a/lib/setup-go.js b/lib/setup-go.js deleted file mode 100644 index f95a75a..0000000 --- a/lib/setup-go.js +++ /dev/null @@ -1,4 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -const main_1 = require("./main"); -main_1.run(); diff --git a/src/main.ts b/src/main.ts index e77eeaf..7f98b11 100644 --- a/src/main.ts +++ b/src/main.ts @@ -10,7 +10,7 @@ export async function run() { // If not supplied then problem matchers will still be setup. Useful for self-hosted. // let versionSpec = core.getInput('go-version'); - + // stable will be true unless false is the exact input // since getting unstable versions should be explicit let stable = Boolean(core.getInput('stable') || 'true');