Disable commands when choco installing and use old versions
This commit is contained in:
@@ -162,7 +162,8 @@ async function apt(tool: Tool, version: string): Promise<void> {
|
||||
|
||||
async function choco(tool: Tool, version: string): Promise<void> {
|
||||
core.info(`Attempting to install ${tool} ${version} using chocolatey`);
|
||||
|
||||
// Choco tries to invoke `add-path` command on earlier versions of ghc, which has been deprecated and fails the step, so disable command execution during this.
|
||||
console.log('::stop-commands::SetupHaskellStopCommands');
|
||||
await exec(
|
||||
'powershell',
|
||||
[
|
||||
@@ -179,8 +180,11 @@ async function choco(tool: Tool, version: string): Promise<void> {
|
||||
ignoreReturnCode: true
|
||||
}
|
||||
);
|
||||
// Add to path automatically because it does not add until the end of the step.
|
||||
core.addPath(getChocoPath(tool, version));
|
||||
console.log('::SetupHaskellStopCommands::'); // Re-enable command execution
|
||||
// Add GHC to path automatically because it does not add until the end of the step and we check the path.
|
||||
if (tool == 'ghc') {
|
||||
core.addPath(getChocoPath(tool, version));
|
||||
}
|
||||
}
|
||||
|
||||
async function ghcupBin(os: OS): Promise<string> {
|
||||
|
||||
14
src/opts.ts
14
src/opts.ts
@@ -28,7 +28,7 @@ export function getDefaults(): Defaults {
|
||||
).inputs;
|
||||
|
||||
const mkVersion = (v: string, vs: string[]): Version => ({
|
||||
version: resolve(inpts[v].default, vs, v),
|
||||
version: resolve(inpts[v].default, vs),
|
||||
supported: vs
|
||||
});
|
||||
|
||||
@@ -39,11 +39,7 @@ export function getDefaults(): Defaults {
|
||||
};
|
||||
}
|
||||
|
||||
function resolve(version: string, supported: string[], type: string): string {
|
||||
// Hard code default windows version to get around ghc-choco using the old add-path commands. Other cli tools don't have this issue and don't have the 8.10.2.2 version
|
||||
if (process.platform === 'win32' && type === 'ghc-version') {
|
||||
return '8.10.2.2';
|
||||
}
|
||||
function resolve(version: string, supported: string[]): string {
|
||||
return version === 'latest'
|
||||
? supported[0]
|
||||
: supported.find(v => v.startsWith(version)) ?? version;
|
||||
@@ -75,17 +71,17 @@ export function getOpts({ghc, cabal, stack}: Defaults): Options {
|
||||
const opts: Options = {
|
||||
ghc: {
|
||||
raw: verInpt.ghc,
|
||||
resolved: resolve(verInpt.ghc, ghc.supported, 'ghc-version'),
|
||||
resolved: resolve(verInpt.ghc, ghc.supported),
|
||||
enable: !stackNoGlobal
|
||||
},
|
||||
cabal: {
|
||||
raw: verInpt.cabal,
|
||||
resolved: resolve(verInpt.cabal, cabal.supported, 'cabal-version'),
|
||||
resolved: resolve(verInpt.cabal, cabal.supported),
|
||||
enable: !stackNoGlobal
|
||||
},
|
||||
stack: {
|
||||
raw: verInpt.stack,
|
||||
resolved: resolve(verInpt.stack, stack.supported, 'stack-version)'),
|
||||
resolved: resolve(verInpt.stack, stack.supported),
|
||||
enable: stackEnable,
|
||||
setup: core.getInput('stack-setup-ghc') !== ''
|
||||
}
|
||||
|
||||
@@ -1,15 +1,10 @@
|
||||
{
|
||||
"ghc": [
|
||||
"8.10.2",
|
||||
"8.10.2.2",
|
||||
"8.10.1",
|
||||
"8.10.1.1",
|
||||
"8.8.4",
|
||||
"8.8.4.1",
|
||||
"8.8.3",
|
||||
"8.8.3.2",
|
||||
"8.8.2",
|
||||
"8.8.2.1",
|
||||
"8.8.1",
|
||||
"8.6.5",
|
||||
"8.6.4",
|
||||
|
||||
Reference in New Issue
Block a user