Skip to content

Commit

Permalink
Avoid leftover files by using temp dir (#150)
Browse files Browse the repository at this point in the history
Fixes: #149
  • Loading branch information
eifinger authored Nov 6, 2024
1 parent a7e1580 commit 2e657c1
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
14 changes: 10 additions & 4 deletions dist/setup/index.js

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

6 changes: 4 additions & 2 deletions src/download/download-latest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,15 @@ export async function downloadLatest(

const downloadPath = await tc.downloadTool(
downloadUrl,
`${artifact}${extension}`,
undefined,
githubToken,
);
let uvExecutablePath: string;
let uvDir: string;
if (platform === "pc-windows-msvc") {
uvDir = await tc.extractZip(downloadPath);
const fullPathWithExtension = `${downloadPath}${extension}`;
await fs.copyFile(downloadPath, fullPathWithExtension);
uvDir = await tc.extractZip(fullPathWithExtension);
// On windows extracting the zip does not create an intermediate directory
uvExecutablePath = path.join(uvDir, "uv.exe");
} else {
Expand Down
6 changes: 4 additions & 2 deletions src/download/download-version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export async function downloadVersion(

const downloadPath = await tc.downloadTool(
downloadUrl,
`${artifact}${extension}`,
undefined,
githubToken,
);
await validateChecksum(
Expand All @@ -53,7 +53,9 @@ export async function downloadVersion(

let uvDir: string;
if (platform === "pc-windows-msvc") {
uvDir = await tc.extractZip(downloadPath);
const fullPathWithExtension = `${downloadPath}${extension}`;
await fs.copyFile(downloadPath, fullPathWithExtension);
uvDir = await tc.extractZip(fullPathWithExtension);
// On windows extracting the zip does not create an intermediate directory
} else {
const extractedDir = await tc.extractTar(downloadPath);
Expand Down

0 comments on commit 2e657c1

Please sign in to comment.