Fix macos ghcup and cabal flags (#4)

* fix short-circuit logic for ghcup based installs of ghc

* fix unrecognized user-config option for cabal v2.0

* update dependencies
This commit is contained in:
Jared Weakly
2020-06-09 09:58:15 -07:00
committed by GitHub
parent c1b48c3995
commit cfefe70615
7 changed files with 6821 additions and 6158 deletions

View File

@@ -85,7 +85,14 @@ async function isInstalled(
.then(() => p)
.catch(() => undefined);
if (installedPath) return success(tool, version, installedPath);
if (installedPath) {
// Make sure that the correct ghc is used, even if ghcup has set a
// default prior to this action being ran.
if (tool === 'ghc' && installedPath === ghcupPath)
await exec(await ghcupBin(os), ['set', version]);
return success(tool, version, installedPath);
}
}
if (tool === 'cabal' && os !== 'win32') {
@@ -172,17 +179,23 @@ async function choco(tool: Tool, version: string): Promise<void> {
]);
}
async function ghcup(tool: Tool, version: string, os: OS): Promise<void> {
core.info(`Attempting to install ${tool} ${version} using ghcup`);
async function ghcupBin(os: OS): Promise<string> {
const v = '0.1.5';
const cachedBin = tc.find('ghcup', v);
if (cachedBin) return join(cachedBin, 'ghcup');
const v = '0.1.4';
const bin = await tc.downloadTool(
`https://downloads.haskell.org/~ghcup/${v}/x86_64-${
`https://downloads.haskell.org/ghcup/${v}/x86_64-${
os === 'darwin' ? 'apple-darwin' : 'linux'
}-ghcup-${v}`
);
await fs.chmod(bin, 0o755);
return join(await tc.cacheFile(bin, 'ghcup', 'ghcup', v), 'ghcup');
}
async function ghcup(tool: Tool, version: string, os: OS): Promise<void> {
core.info(`Attempting to install ${tool} ${version} using ghcup`);
const bin = await ghcupBin(os);
await exec(bin, [tool === 'ghc' ? 'install' : 'install-cabal', version]);
if (tool === 'ghc') await exec(bin, ['set', version]);
}