Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
ffried committed Oct 24, 2022
1 parent 27accbc commit 8abdca3
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import * as core from '@actions/core';
import {getExecOutput} from "@actions/exec";
import { getExecOutput } from '@actions/exec';
import * as tools from '@actions/tool-cache';
import * as io from '@actions/io';
import * as github from '@actions/github';
import * as fs from "fs";
import * as util from "util";
import * as path from "path";

import * as fs from 'fs';
import * as util from 'util';
import * as path from 'path';

async function runCmd(cmd: string, args?: string[]): Promise<string> {
const output = await getExecOutput(cmd, args);
Expand Down Expand Up @@ -44,9 +43,9 @@ async function install(installBase: string, branchName: string, versionTag: stri
return await util.promisify(fs.mkdtemp)('SwiftyActions');
});

const swiftPkg = path.join(tempPath, "swift.tar.gz");
const swiftSig = path.join(tempPath, "swift.tar.gz.sig");
const allKeysFile = path.join(tempPath, "all-keys.asc");
const swiftPkg = path.join(tempPath, 'swift.tar.gz');
const swiftSig = path.join(tempPath, 'swift.tar.gz.sig');
const allKeysFile = path.join(tempPath, 'all-keys.asc');
await core.group('Downloading files', async () => {
const swiftURL = `https://download.swift.org/${branchName}/${platform.split('.').join('')}/${versionTag}/${versionTag}-${platform}.tar.gz`;
await Promise.all([
Expand All @@ -73,8 +72,8 @@ async function install(installBase: string, branchName: string, versionTag: stri

async function main() {
switch (process.platform) {
case "linux": break;
default: throw new Error("This action can only install Swift on linux!");
case 'linux': break;
default: throw new Error('This action can only install Swift on linux!');
}

core.startGroup('Validate input');
Expand All @@ -83,7 +82,7 @@ async function main() {
let swiftRelease: string;
let swiftBranch: string, swiftVersion: string;
if (!swiftReleaseInput) {
core.info("`release-version` was not set. Requiring `branch-name` and `version-tag` parameters!");
core.info('`release-version` was not set. Requiring `branch-name` and `version-tag` parameters!');
swiftBranch = core.getInput('branch-name', { required: true });
swiftVersion = core.getInput('version-tag', { required: true });
swiftRelease = swiftReleaseInput;
Expand Down Expand Up @@ -198,15 +197,15 @@ async function main() {
});
}
} else {
core.info("Skipping installation of dependencies...");
core.info('Skipping installation of dependencies...');
}

const versionIdentifier = `${swiftBranch}-${swiftVersion}-${swiftPlatform}`;
const mangledName = `swift.${versionIdentifier}`;
const cachedVersion = tools.find(mangledName, '1.0.0');
const swiftInstallBase = path.join('/opt/swift', versionIdentifier);
if (cachedVersion) {
core.info("Using cached version!");
core.info('Using cached version!');
await io.cp(cachedVersion, swiftInstallBase, { recursive: true });
} else {
await install(swiftInstallBase, swiftBranch, swiftVersion, swiftPlatform);
Expand Down

0 comments on commit 8abdca3

Please sign in to comment.