From 1dedc0776a9b8e07e79cb9a5644c1c03aac07992 Mon Sep 17 00:00:00 2001 From: Alif Rachmawadi Date: Mon, 26 Aug 2019 10:59:10 +0700 Subject: [PATCH] remove unused hacks --- lib/installer.js | 48 ++------------------------------------------ src/installer.ts | 52 ++---------------------------------------------- 2 files changed, 4 insertions(+), 96 deletions(-) diff --git a/lib/installer.js b/lib/installer.js index 50f01f7..9a62ca7 100644 --- a/lib/installer.js +++ b/lib/installer.js @@ -14,9 +14,6 @@ var __importStar = (this && this.__importStar) || function (mod) { result["default"] = mod; return result; }; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; Object.defineProperty(exports, "__esModule", { value: true }); const core = __importStar(require("@actions/core")); const io = __importStar(require("@actions/io")); @@ -25,8 +22,6 @@ const fs = __importStar(require("fs")); const path = __importStar(require("path")); const restm = __importStar(require("typed-rest-client/RestClient")); const semver = __importStar(require("semver")); -const v4_1 = __importDefault(require("uuid/v4")); -const exec_1 = require("@actions/exec/lib/exec"); const IS_WINDOWS = process.platform === 'win32'; const IS_DARWIN = process.platform === 'darwin'; const IS_LINUX = process.platform === 'linux'; @@ -122,52 +117,13 @@ function extractFile(file, destDir) { throw new Error(`Failed to extract ${file} - it is a directory`); } if ('tar.xz' === extName()) { - yield extractTarXz(file, destDir); + yield tc.extractTar(file, destDir, 'x'); } else { - if (IS_DARWIN) { - yield extractZipDarwin(file, destDir); - } - else { - yield tc.extractZip(file, destDir); - } + yield tc.extractZip(file, destDir); } }); } -/** - * Extract a tar.xz - * - * @param file path to the tar.xz - * @param dest destination directory. Optional. - * @returns path to the destination directory - */ -function extractTarXz(file, dest) { - return __awaiter(this, void 0, void 0, function* () { - if (!file) { - throw new Error("parameter 'file' is required"); - } - dest = dest || (yield _createExtractFolder(dest)); - const tarPath = yield io.which('tar', true); - yield exec_1.exec(`"${tarPath}"`, ['xC', dest, '-f', file]); - return dest; - }); -} -exports.extractTarXz = extractTarXz; -function _createExtractFolder(dest) { - return __awaiter(this, void 0, void 0, function* () { - if (!dest) { - dest = path.join(tempDirectory, v4_1.default()); - } - yield io.mkdirP(dest); - return dest; - }); -} -function extractZipDarwin(file, dest) { - return __awaiter(this, void 0, void 0, function* () { - const unzipPath = path.join(__dirname, '..', 'scripts', 'externals', 'unzip-darwin'); - yield exec_1.exec(`"${unzipPath}"`, [file], { cwd: dest }); - }); -} function determineVersion(version, channel) { return __awaiter(this, void 0, void 0, function* () { if (version.endsWith('.x') || version === '') { diff --git a/src/installer.ts b/src/installer.ts index 57ef329..747f112 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -5,8 +5,6 @@ import * as fs from 'fs'; import * as path from 'path'; import * as restm from 'typed-rest-client/RestClient'; import * as semver from 'semver'; -import uuidV4 from 'uuid/v4'; -import {exec} from '@actions/exec/lib/exec'; const IS_WINDOWS = process.platform === 'win32'; const IS_DARWIN = process.platform === 'darwin'; @@ -130,58 +128,12 @@ async function extractFile(file: string, destDir: string): Promise { } if ('tar.xz' === extName()) { - await extractTarXz(file, destDir); + await tc.extractTar(file, destDir, 'x'); } else { - if (IS_DARWIN) { - await extractZipDarwin(file, destDir); - } else { - await tc.extractZip(file, destDir); - } + await tc.extractZip(file, destDir); } } -/** - * Extract a tar.xz - * - * @param file path to the tar.xz - * @param dest destination directory. Optional. - * @returns path to the destination directory - */ -export async function extractTarXz( - file: string, - dest?: string -): Promise { - if (!file) { - throw new Error("parameter 'file' is required"); - } - - dest = dest || (await _createExtractFolder(dest)); - const tarPath: string = await io.which('tar', true); - await exec(`"${tarPath}"`, ['xC', dest, '-f', file]); - - return dest; -} - -async function _createExtractFolder(dest?: string): Promise { - if (!dest) { - dest = path.join(tempDirectory, uuidV4()); - } - - await io.mkdirP(dest); - return dest; -} - -async function extractZipDarwin(file: string, dest: string): Promise { - const unzipPath = path.join( - __dirname, - '..', - 'scripts', - 'externals', - 'unzip-darwin' - ); - await exec(`"${unzipPath}"`, [file], {cwd: dest}); -} - async function determineVersion( version: string, channel: string