Ignore exit code for choco and ghcup installs

This means that they can now fallback to alternatve install options
This commit is contained in:
Luke Lau
2020-07-27 13:27:27 +01:00
parent d8110230de
commit c2e19a92bb
2 changed files with 31 additions and 15 deletions

10
dist/index.js vendored
View File

@@ -11111,7 +11111,9 @@ async function choco(tool, version) {
'-m',
'--no-progress',
'-r'
]);
], {
ignoreReturnCode: true
});
}
async function ghcupBin(os) {
const v = '0.1.8';
@@ -11125,8 +11127,10 @@ async function ghcupBin(os) {
async function ghcup(tool, version, os) {
core.info(`Attempting to install ${tool} ${version} using ghcup`);
const bin = await ghcupBin(os);
await exec_1.exec(bin, [tool === 'ghc' ? 'install' : 'install-cabal', version]);
if (tool === 'ghc')
const returnCode = await exec_1.exec(bin, [tool === 'ghc' ? 'install' : 'install-cabal', version], {
ignoreReturnCode: true
});
if (returnCode === 0 && tool === 'ghc')
await exec_1.exec(bin, ['set', version]);
}

View File

@@ -170,16 +170,22 @@ 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`);
await exec('powershell', [
'choco',
'install',
tool,
'--version',
version,
'-m',
'--no-progress',
'-r'
]);
await exec(
'powershell',
[
'choco',
'install',
tool,
'--version',
version,
'-m',
'--no-progress',
'-r'
],
{
ignoreReturnCode: true
}
);
}
async function ghcupBin(os: OS): Promise<string> {
@@ -199,6 +205,12 @@ async function ghcupBin(os: OS): Promise<string> {
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]);
const returnCode = await exec(
bin,
[tool === 'ghc' ? 'install' : 'install-cabal', version],
{
ignoreReturnCode: true
}
);
if (returnCode === 0 && tool === 'ghc') await exec(bin, ['set', version]);
}