Handle defaults up a level
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user