Skip to content

Commit

Permalink
Extract arch string conversion into a function
Browse files Browse the repository at this point in the history
  • Loading branch information
elopez committed Oct 24, 2023
1 parent 3e00b2f commit 4c14628
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 11 deletions.
19 changes: 16 additions & 3 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 16 additions & 3 deletions lib/installer.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 19 additions & 5 deletions src/installer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,9 +232,22 @@ export async function resetTool(
}
}

async function stackArchString(arch: Arch): Promise<string> {
switch (arch) {
case 'arm64':
return Promise.resolve('aarch64');
case 'x64':
return Promise.resolve('x86_64');
default:
const err = `Unsupported architecture: ${arch}`;
core.error(err);
return Promise.reject(err);
}
}

async function stack(version: string, os: OS, arch: Arch): Promise<void> {
core.info(`Attempting to install stack ${version}`);
const binArch = arch === 'arm64' ? 'aarch64' : 'x86_64';
const binArch = await stackArchString(arch);
core.info(`Attempting to install stack ${version} for arch ${binArch}`);
const build = {
linux: `linux-${binArch}${
compareVersions(version, '2.3.1') >= 0 ? '' : '-static'
Expand Down Expand Up @@ -326,10 +339,11 @@ async function ghcupBin(os: OS, arch: Arch): Promise<string> {
const cachedBin = tc.find('ghcup', ghcup_version);
if (cachedBin) return join(cachedBin, 'ghcup');

const binArch = await stackArchString(arch);
const bin = await tc.downloadTool(
`https://downloads.haskell.org/ghcup/${ghcup_version}/${
arch === 'arm64' ? 'aarch64' : 'x86_64'
}-${os === 'darwin' ? 'apple-darwin' : 'linux'}-ghcup-${ghcup_version}`
`https://downloads.haskell.org/ghcup/${ghcup_version}/${binArch}-${
os === 'darwin' ? 'apple-darwin' : 'linux'
}-ghcup-${ghcup_version}`
);
await afs.chmod(bin, 0o755);
return join(
Expand Down

0 comments on commit 4c14628

Please sign in to comment.