Handle defaults up a level

This commit is contained in:
Timothy Clem
2019-09-23 20:32:15 -07:00
parent 8cd05073c6
commit fd2c5e7601
3 changed files with 20 additions and 6 deletions

View File

@@ -18,13 +18,23 @@ var __importStar = (this && this.__importStar) || function (mod) {
Object.defineProperty(exports, "__esModule", { value: true });
const core = __importStar(require("@actions/core"));
const installer_1 = require("./installer");
const defaultGHCVersion = '8.6.5';
const defualtCabalVersion = '3.0';
function run() {
return __awaiter(this, void 0, void 0, function* () {
try {
yield installer_1.cacheHaskellTool('/opt', 'ghc');
yield installer_1.cacheHaskellTool('/opt', 'cabal');
let ghcVersion = core.getInput('ghc-version');
if (!ghcVersion) {
ghcVersion = defaultGHCVersion;
}
yield installer_1.findHaskellGHCVersion(ghcVersion);
let cabalVersion = core.getInput('cabal-version');
if (!cabalVersion) {
cabalVersion = defualtCabalVersion;
}
yield installer_1.findHaskellCabalVersion(cabalVersion);
}
catch (error) {
core.setFailed(error.message);

View File

@@ -17,16 +17,10 @@ export async function cacheHaskellTool(installDir: string, tool: string) {
}
export async function findHaskellGHCVersion(version: string) {
if (!version) {
version = '8.6.5';
}
return _findHaskellToolVersion('ghc', version);
}
export async function findHaskellCabalVersion(version: string) {
if (!version) {
version = '3.0';
}
return _findHaskellToolVersion('cabal', version);
}

View File

@@ -5,14 +5,24 @@ import {
cacheHaskellTool
} from './installer';
const defaultGHCVersion = '8.6.5';
const defualtCabalVersion = '3.0';
async function run() {
try {
await cacheHaskellTool('/opt', 'ghc');
await cacheHaskellTool('/opt', 'cabal');
let ghcVersion = core.getInput('ghc-version');
if (!ghcVersion) {
ghcVersion = defaultGHCVersion;
}
await findHaskellGHCVersion(ghcVersion);
let cabalVersion = core.getInput('cabal-version');
if (!cabalVersion) {
cabalVersion = defualtCabalVersion;
}
await findHaskellCabalVersion(cabalVersion);
} catch (error) {
core.setFailed(error.message);