From 11ef85623b570154d4b208a8d7304c79869dc492 Mon Sep 17 00:00:00 2001 From: Mark Delk Date: Sun, 26 Nov 2023 00:50:06 -0600 Subject: [PATCH] fix :bug: when extracting --- dist/index.js | 19 +++++++++++++++---- index.js | 9 +++++++-- test.js | 4 ++++ versions.js | 10 ++++++++-- 4 files changed, 34 insertions(+), 8 deletions(-) diff --git a/dist/index.js b/dist/index.js index 89b7fe2..12993b3 100644 --- a/dist/index.js +++ b/dist/index.js @@ -80701,10 +80701,16 @@ var require_versions = __commonJS({ darwin: "macos-x86_64", win32: "windows-x86_64" }[platform]; - const downloadUrl = `https://ziglang.org/builds/zig-${addrhost}-${version2}.${ext}`; + const fileWithoutFileType = `zig-${addrhost}-${version2}`; + const downloadUrl = `https://ziglang.org/builds/${fileWithoutFileType}.${ext}`; const versionWithoutBuildHash = semver2.clean(version2); const variantName = `zig-${addrhost}-${versionWithoutBuildHash}`; - return { downloadUrl, variantName, version: versionWithoutBuildHash }; + return { + downloadUrl, + fileWithoutFileType, + variantName, + version: versionWithoutBuildHash + }; } __name(resolveCommit2, "resolveCommit"); function getJSON(opts) { @@ -80761,7 +80767,12 @@ var { var TOOL_NAME = "zig"; async function downloadZig(platform, version2, useCache = true) { const ext = extForPlatform(platform); - const { downloadUrl, variantName, version: useVersion } = version2.includes("+") ? resolveCommit(platform, version2) : await resolveVersion(platform, version2); + const { + downloadUrl, + fileWithoutFileType, + variantName, + version: useVersion + } = version2.includes("+") ? resolveCommit(platform, version2) : await resolveVersion(platform, version2); const cachedPath = toolCache.find(TOOL_NAME, useVersion); if (cachedPath) { actions.info(`using cached zig install: ${cachedPath}`); @@ -80780,7 +80791,7 @@ async function downloadZig(platform, version2, useCache = true) { actions.info(`no cached version found. downloading zig ${variantName}`); const downloadPath = await toolCache.downloadTool(downloadUrl); const zigPath = ext === "zip" ? await toolCache.extractZip(downloadPath) : await toolCache.extractTar(downloadPath, void 0, "x"); - const binPath = path.join(zigPath, variantName); + const binPath = path.join(zigPath, fileWithoutFileType); const cachePath = await toolCache.cacheDir(binPath, TOOL_NAME, useVersion); if (useCache) { actions.info(`adding zig ${useVersion} at ${cachePath} to local cache ${cacheKey}`); diff --git a/index.js b/index.js index 6f55d2b..892c607 100644 --- a/index.js +++ b/index.js @@ -17,7 +17,12 @@ const TOOL_NAME = 'zig' async function downloadZig (platform, version, useCache = true) { const ext = extForPlatform(platform) - const { downloadUrl, variantName, version: useVersion } = version.includes('+') + const { + downloadUrl, + fileWithoutFileType, + variantName, + version: useVersion + } = version.includes('+') ? resolveCommit(platform, version) : await resolveVersion(platform, version) @@ -44,7 +49,7 @@ async function downloadZig (platform, version, useCache = true) { ? await toolCache.extractZip(downloadPath) : await toolCache.extractTar(downloadPath, undefined, 'x') - const binPath = path.join(zigPath, variantName) + const binPath = path.join(zigPath, fileWithoutFileType) const cachePath = await toolCache.cacheDir(binPath, TOOL_NAME, useVersion) if (useCache) { diff --git a/test.js b/test.js index 8db503b..ce8a1dd 100644 --- a/test.js +++ b/test.js @@ -7,21 +7,25 @@ const { async function test () { assert.deepEqual(resolveCommit('linux', '0.6.0+4b48fccad'), { downloadUrl: 'https://ziglang.org/builds/zig-linux-x86_64-0.6.0+4b48fccad.tar.xz', + fileWithoutFileType: 'zig-linux-x86_64-0.6.0+4b48fccad', variantName: 'zig-linux-x86_64-0.6.0', version: '0.6.0' }) assert.deepEqual(resolveCommit('win32', '0.6.0+4b48fccad'), { downloadUrl: 'https://ziglang.org/builds/zig-windows-x86_64-0.6.0+4b48fccad.zip', + fileWithoutFileType: 'zig-windows-x86_64-0.6.0+4b48fccad', variantName: 'zig-windows-x86_64-0.6.0', version: '0.6.0' }) assert.deepEqual(resolveCommit('win32', '0.12.0-dev.1092+68ed78775'), { downloadUrl: 'https://ziglang.org/builds/zig-windows-x86_64-0.12.0-dev.1092+68ed78775.zip', + fileWithoutFileType: 'zig-windows-x86_64-0.12.0-dev.1092+68ed78775', variantName: 'zig-windows-x86_64-0.12.0-dev.1092', version: '0.12.0-dev.1092' }) assert.deepEqual(resolveCommit('darwin', '0.12.0-dev.1150+3c22cecee'), { downloadUrl: 'https://ziglang.org/builds/zig-macos-x86_64-0.12.0-dev.1150+3c22cecee.tar.xz', + fileWithoutFileType: 'zig-macos-x86_64-0.12.0-dev.1150+3c22cecee', variantName: 'zig-macos-x86_64-0.12.0-dev.1150', version: '0.12.0-dev.1150' }) diff --git a/versions.js b/versions.js index ccfc473..c4db9ee 100644 --- a/versions.js +++ b/versions.js @@ -18,12 +18,18 @@ function resolveCommit (platform, version) { win32: 'windows-x86_64' }[platform] - const downloadUrl = `https://ziglang.org/builds/zig-${addrhost}-${version}.${ext}` + const fileWithoutFileType = `zig-${addrhost}-${version}` + const downloadUrl = `https://ziglang.org/builds/${fileWithoutFileType}.${ext}` const versionWithoutBuildHash = semver.clean(version) const variantName = `zig-${addrhost}-${versionWithoutBuildHash}` - return { downloadUrl, variantName, version: versionWithoutBuildHash } + return { + downloadUrl, + fileWithoutFileType, + variantName, + version: versionWithoutBuildHash + } } function getJSON (opts) {