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 });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
const core = __importStar(require("@actions/core"));
|
const core = __importStar(require("@actions/core"));
|
||||||
const installer_1 = require("./installer");
|
const installer_1 = require("./installer");
|
||||||
|
const defaultGHCVersion = '8.6.5';
|
||||||
|
const defualtCabalVersion = '3.0';
|
||||||
function run() {
|
function run() {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
try {
|
try {
|
||||||
yield installer_1.cacheHaskellTool('/opt', 'ghc');
|
yield installer_1.cacheHaskellTool('/opt', 'ghc');
|
||||||
yield installer_1.cacheHaskellTool('/opt', 'cabal');
|
yield installer_1.cacheHaskellTool('/opt', 'cabal');
|
||||||
let ghcVersion = core.getInput('ghc-version');
|
let ghcVersion = core.getInput('ghc-version');
|
||||||
|
if (!ghcVersion) {
|
||||||
|
ghcVersion = defaultGHCVersion;
|
||||||
|
}
|
||||||
yield installer_1.findHaskellGHCVersion(ghcVersion);
|
yield installer_1.findHaskellGHCVersion(ghcVersion);
|
||||||
|
let cabalVersion = core.getInput('cabal-version');
|
||||||
|
if (!cabalVersion) {
|
||||||
|
cabalVersion = defualtCabalVersion;
|
||||||
|
}
|
||||||
|
yield installer_1.findHaskellCabalVersion(cabalVersion);
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
core.setFailed(error.message);
|
core.setFailed(error.message);
|
||||||
|
|||||||
@@ -17,16 +17,10 @@ export async function cacheHaskellTool(installDir: string, tool: string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function findHaskellGHCVersion(version: string) {
|
export async function findHaskellGHCVersion(version: string) {
|
||||||
if (!version) {
|
|
||||||
version = '8.6.5';
|
|
||||||
}
|
|
||||||
return _findHaskellToolVersion('ghc', version);
|
return _findHaskellToolVersion('ghc', version);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function findHaskellCabalVersion(version: string) {
|
export async function findHaskellCabalVersion(version: string) {
|
||||||
if (!version) {
|
|
||||||
version = '3.0';
|
|
||||||
}
|
|
||||||
return _findHaskellToolVersion('cabal', version);
|
return _findHaskellToolVersion('cabal', version);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,14 +5,24 @@ import {
|
|||||||
cacheHaskellTool
|
cacheHaskellTool
|
||||||
} from './installer';
|
} from './installer';
|
||||||
|
|
||||||
|
const defaultGHCVersion = '8.6.5';
|
||||||
|
const defualtCabalVersion = '3.0';
|
||||||
|
|
||||||
async function run() {
|
async function run() {
|
||||||
try {
|
try {
|
||||||
await cacheHaskellTool('/opt', 'ghc');
|
await cacheHaskellTool('/opt', 'ghc');
|
||||||
await cacheHaskellTool('/opt', 'cabal');
|
await cacheHaskellTool('/opt', 'cabal');
|
||||||
|
|
||||||
let ghcVersion = core.getInput('ghc-version');
|
let ghcVersion = core.getInput('ghc-version');
|
||||||
|
if (!ghcVersion) {
|
||||||
|
ghcVersion = defaultGHCVersion;
|
||||||
|
}
|
||||||
await findHaskellGHCVersion(ghcVersion);
|
await findHaskellGHCVersion(ghcVersion);
|
||||||
|
|
||||||
let cabalVersion = core.getInput('cabal-version');
|
let cabalVersion = core.getInput('cabal-version');
|
||||||
|
if (!cabalVersion) {
|
||||||
|
cabalVersion = defualtCabalVersion;
|
||||||
|
}
|
||||||
await findHaskellCabalVersion(cabalVersion);
|
await findHaskellCabalVersion(cabalVersion);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
core.setFailed(error.message);
|
core.setFailed(error.message);
|
||||||
|
|||||||
Reference in New Issue
Block a user