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:
@@ -1,9 +1,20 @@
|
||||
import * as core from '@actions/core';
|
||||
import * as fs from 'fs';
|
||||
import {getOpts, getDefaults, Tool} from './opts';
|
||||
import {installTool} from './installer';
|
||||
import type {OS} from './opts';
|
||||
import {exec} from '@actions/exec';
|
||||
|
||||
async function cabalConfig(): Promise<string> {
|
||||
let out = Buffer.from('');
|
||||
const append = (b: Buffer): Buffer => (out = Buffer.concat([out, b]));
|
||||
await exec('cabal', ['--help'], {
|
||||
silent: true,
|
||||
listeners: {stdout: append, stderr: append}
|
||||
});
|
||||
return out.toString().trim().split('\n').slice(-1)[0].trim();
|
||||
}
|
||||
|
||||
(async () => {
|
||||
try {
|
||||
core.info('Preparing to setup a Haskell environment');
|
||||
@@ -21,16 +32,19 @@ import {exec} from '@actions/exec';
|
||||
|
||||
if (opts.cabal.enable)
|
||||
await core.group('Setting up cabal', async () => {
|
||||
await exec(
|
||||
'cabal user-config update -a "http-transport: plain-http" -v3'
|
||||
);
|
||||
await exec('cabal', ['update']);
|
||||
await exec('cabal', ['user-config', 'update'], {silent: true});
|
||||
const configFile = await cabalConfig();
|
||||
fs.appendFileSync(configFile, 'http-transport: plain-http\n');
|
||||
|
||||
if (process.platform === 'win32') {
|
||||
await exec('cabal user-config update -a "store-dir: C:\\sr" -v3');
|
||||
fs.appendFileSync(configFile, 'store-dir: C:\\sr\n');
|
||||
core.setOutput('cabal-store', 'C:\\sr');
|
||||
} else {
|
||||
core.setOutput('cabal-store', `${process.env.HOME}/.cabal/store`);
|
||||
}
|
||||
|
||||
await exec('cabal user-config update');
|
||||
if (!opts.stack.enable) await exec('cabal update');
|
||||
});
|
||||
} catch (error) {
|
||||
core.setFailed(error.message);
|
||||
|
||||
Reference in New Issue
Block a user