Skip to content

Commit

Permalink
cleanup: Move dist URL prefix to constant
Browse files Browse the repository at this point in the history
  • Loading branch information
tarampampam committed Jun 19, 2024
1 parent e248b2f commit 8cb4557
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,19 +166,20 @@ async function getVersionCommitHash(githubAuthToken, version) {
* @throws {Error} Unsupported platform or architecture
*/
function getDistUrl(platform, arch, version, versionCommitHash) {
const baseUrl = 'https://gethstore.blob.core.windows.net/builds'
const shortHash = versionCommitHash.substring(0, 8)

switch (platform) {
case 'linux': {
switch (arch) {
case 'x64': // Amd64
return `https://gethstore.blob.core.windows.net/builds/geth-alltools-linux-amd64-${version}-${shortHash}.tar.gz`
return `${baseUrl}/geth-alltools-linux-amd64-${version}-${shortHash}.tar.gz`

case 'x32':
return `https://gethstore.blob.core.windows.net/builds/geth-alltools-linux-386-${version}-${shortHash}.tar.gz`
return `${baseUrl}/geth-alltools-linux-386-${version}-${shortHash}.tar.gz`

case 'arm64':
return `https://gethstore.blob.core.windows.net/builds/geth-alltools-linux-arm64-${version}-${shortHash}.tar.gz`
return `${baseUrl}/geth-alltools-linux-arm64-${version}-${shortHash}.tar.gz`
}

throw new Error(`Unsupported linux architecture (${arch})`)
Expand All @@ -187,10 +188,10 @@ function getDistUrl(platform, arch, version, versionCommitHash) {
case 'darwin': {
switch (arch) {
case 'x64':
return `https://gethstore.blob.core.windows.net/builds/geth-alltools-darwin-amd64-${version}-${shortHash}.tar.gz`
return `${baseUrl}/geth-alltools-darwin-amd64-${version}-${shortHash}.tar.gz`

case 'arm64': // available since 1.13.5 // https://github.com/gacts/install-geth-tools/pull/68 TY @antazoey
return `https://gethstore.blob.core.windows.net/builds/geth-alltools-darwin-arm64-${version}-${shortHash}.tar.gz`;
return `${baseUrl}/geth-alltools-darwin-arm64-${version}-${shortHash}.tar.gz`;
}

throw new Error(`Unsupported MacOS architecture (${arch})`)
Expand All @@ -199,10 +200,10 @@ function getDistUrl(platform, arch, version, versionCommitHash) {
case 'win32': {
switch (arch) {
case 'x64': // Amd64
return `https://gethstore.blob.core.windows.net/builds/geth-alltools-windows-amd64-${version}-${shortHash}.zip`
return `${baseUrl}/geth-alltools-windows-amd64-${version}-${shortHash}.zip`

case 'x32': // 386
return `https://gethstore.blob.core.windows.net/builds/geth-alltools-windows-386-${version}-${shortHash}.zip`
return `${baseUrl}/geth-alltools-windows-386-${version}-${shortHash}.zip`
}

throw new Error(`Unsupported windows architecture (${arch})`)
Expand Down

0 comments on commit 8cb4557

Please sign in to comment.