diff --git a/lib/setup-haskell.js b/lib/setup-haskell.js index b8e48ed..0493ba6 100644 --- a/lib/setup-haskell.js +++ b/lib/setup-haskell.js @@ -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); diff --git a/src/installer.ts b/src/installer.ts index b9b0fa5..e63a3e3 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -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); } diff --git a/src/setup-haskell.ts b/src/setup-haskell.ts index c98045f..f7853a8 100644 --- a/src/setup-haskell.ts +++ b/src/setup-haskell.ts @@ -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);