On windows extracting the zip does not create an intermediate directory

This commit is contained in:
Kevin Stillhammer 2024-08-24 09:20:02 +02:00
parent 4203354a33
commit 3e3aecd6b6
No known key found for this signature in database
3 changed files with 8 additions and 23 deletions

BIN
dist/setup/index.js generated vendored

Binary file not shown.

View File

@ -29,8 +29,8 @@ export async function downloadLatest(
let uvExecutablePath: string
let uvDir: string
if (platform === 'pc-windows-msvc') {
const extractedDir = await tc.extractZip(downloadPath)
uvDir = path.join(extractedDir, artifact)
uvDir = await tc.extractZip(downloadPath)
// On windows extracting the zip does not create an intermediate directory
uvExecutablePath = path.join(uvDir, 'uv.exe')
} else {
const extractedDir = await tc.extractTar(downloadPath)

View File

@ -5,11 +5,6 @@ import {OWNER, REPO, TOOL_CACHE_NAME} from '../utils/utils'
import {Architecture, Platform} from '../utils/platforms'
import {validateChecksum} from './checksum/checksum'
import * as fs from 'fs'
import * as util from 'util'
const readdir = util.promisify(fs.readdir)
export function tryGetFromToolCache(
arch: Architecture,
version: string
@ -43,24 +38,14 @@ export async function downloadVersion(
)
await validateChecksum(checkSum, downloadPath, arch, platform, version)
let extractedDir: string
let uvDir: string
if (platform === 'pc-windows-msvc') {
extractedDir = await tc.extractZip(downloadPath)
const files = await readdir(extractedDir)
core.info(
`Contents of extracted directory ${extractedDir}: ${files.join(', ')}`
)
const uvDir = path.join(extractedDir, artifact)
const uvfiles = await readdir(uvDir)
core.info(`Contents of directory ${uvDir}: ${uvfiles.join(', ')}`)
uvDir = await tc.extractZip(downloadPath)
// On windows extracting the zip does not create an intermediate directory
} else {
extractedDir = await tc.extractTar(downloadPath)
const extractedDir = await tc.extractTar(downloadPath)
uvDir = path.join(extractedDir, artifact)
}
return await tc.cacheDir(
path.join(extractedDir, artifact),
TOOL_CACHE_NAME,
version,
arch
)
return await tc.cacheDir(uvDir, TOOL_CACHE_NAME, version, arch)
}