From 09d569423fce97ceb27fe619ac5a0358a9daf4e6 Mon Sep 17 00:00:00 2001 From: Brandon Chinn Date: Mon, 3 Jul 2023 16:32:24 -0700 Subject: [PATCH] Support latest-nightly --- README.md | 1 + dist/index.js | 21 +++++++++++++++------ lib/installer.js | 21 +++++++++++++++------ src/installer.ts | 20 ++++++++++++++------ 4 files changed, 45 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 3813355..c3a2eea 100644 --- a/README.md +++ b/README.md @@ -236,6 +236,7 @@ E.g., `8.10` will be resolved to `8.10.7`, and so will `8`. **GHC:** +- `latest-nightly` - `latest` (default) - `9.6.2` `9.6` - `9.6.1` diff --git a/dist/index.js b/dist/index.js index c7b396f..269a33f 100644 --- a/dist/index.js +++ b/dist/index.js @@ -13400,12 +13400,21 @@ async function installTool(tool, version, os) { } switch (os) { case 'linux': - if (tool === 'ghc' && (0, compare_versions_1.compareVersions)('8.3', version)) { - // Andreas, 2022-12-09: The following errors out if we are not ubuntu-20.04. - // Atm, I do not know how to check whether we are on ubuntu-20.04. - // So, ignore the error. - // if (!(await aptLibCurses5())) break; - await aptLibNCurses5(); + if (tool === 'ghc') { + if (version === 'latest-nightly') { + await exec(await ghcupBin(os), [ + 'config', + 'add-release-channel', + 'https://ghc.gitlab.haskell.org/ghcup-metadata/ghcup-nightlies-0.0.7.yaml' + ]); + } + else if ((0, compare_versions_1.compareVersions)('8.3', version)) { + // Andreas, 2022-12-09: The following errors out if we are not ubuntu-20.04. + // Atm, I do not know how to check whether we are on ubuntu-20.04. + // So, ignore the error. + // if (!(await aptLibCurses5())) break; + await aptLibNCurses5(); + } } await ghcup(tool, version, os); if (await isInstalled(tool, version, os)) diff --git a/lib/installer.js b/lib/installer.js index 798b54f..26c6815 100644 --- a/lib/installer.js +++ b/lib/installer.js @@ -155,12 +155,21 @@ async function installTool(tool, version, os) { } switch (os) { case 'linux': - if (tool === 'ghc' && (0, compare_versions_1.compareVersions)('8.3', version)) { - // Andreas, 2022-12-09: The following errors out if we are not ubuntu-20.04. - // Atm, I do not know how to check whether we are on ubuntu-20.04. - // So, ignore the error. - // if (!(await aptLibCurses5())) break; - await aptLibNCurses5(); + if (tool === 'ghc') { + if (version === 'latest-nightly') { + await exec(await ghcupBin(os), [ + 'config', + 'add-release-channel', + 'https://ghc.gitlab.haskell.org/ghcup-metadata/ghcup-nightlies-0.0.7.yaml' + ]); + } + else if ((0, compare_versions_1.compareVersions)('8.3', version)) { + // Andreas, 2022-12-09: The following errors out if we are not ubuntu-20.04. + // Atm, I do not know how to check whether we are on ubuntu-20.04. + // So, ignore the error. + // if (!(await aptLibCurses5())) break; + await aptLibNCurses5(); + } } await ghcup(tool, version, os); if (await isInstalled(tool, version, os)) diff --git a/src/installer.ts b/src/installer.ts index 9d30f41..3b17332 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -165,12 +165,20 @@ export async function installTool( switch (os) { case 'linux': - if (tool === 'ghc' && compareVersions('8.3', version)) { - // Andreas, 2022-12-09: The following errors out if we are not ubuntu-20.04. - // Atm, I do not know how to check whether we are on ubuntu-20.04. - // So, ignore the error. - // if (!(await aptLibCurses5())) break; - await aptLibNCurses5(); + if (tool === 'ghc') { + if (version === 'latest-nightly') { + await exec(await ghcupBin(os), [ + 'config', + 'add-release-channel', + 'https://ghc.gitlab.haskell.org/ghcup-metadata/ghcup-nightlies-0.0.7.yaml' + ]); + } else if (compareVersions('8.3', version)) { + // Andreas, 2022-12-09: The following errors out if we are not ubuntu-20.04. + // Atm, I do not know how to check whether we are on ubuntu-20.04. + // So, ignore the error. + // if (!(await aptLibCurses5())) break; + await aptLibNCurses5(); + } } await ghcup(tool, version, os); if (await isInstalled(tool, version, os)) return;