Skip to content

Commit

Permalink
On windows extracting the zip does not create an intermediate directory
Browse files Browse the repository at this point in the history
  • Loading branch information
eifinger committed Aug 24, 2024
1 parent 4203354 commit 3e3aecd
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 37 deletions.
22 changes: 8 additions & 14 deletions dist/setup/index.js

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

4 changes: 2 additions & 2 deletions src/download/download-latest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
27 changes: 6 additions & 21 deletions src/download/download-version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
}

0 comments on commit 3e3aecd

Please sign in to comment.