5
0
mirror of https://github.com/astral-sh/setup-uv.git synced 2025-12-17 11:05:59 +00:00

fix relative paths starting with dots (#500)

Fixes: #499
This commit is contained in:
Kevin Stillhammer
2025-07-23 19:31:57 +02:00
committed by GitHub
parent 2c7142f755
commit e92bafb625
4 changed files with 71 additions and 11 deletions

View File

@@ -1,11 +1,11 @@
import * as core from "@actions/core";
import path from "node:path";
export const workingDirectory = core.getInput("working-directory");
export const version = core.getInput("version");
export const versionFile = core.getInput("version-file");
export const versionFile = getVersionFile();
export const pythonVersion = core.getInput("python-version");
export const activateEnvironment = core.getBooleanInput("activate-environment");
export const workingDirectory = core.getInput("working-directory");
export const checkSum = core.getInput("checksum");
export const enableCache = getEnableCache();
export const cacheSuffix = core.getInput("cache-suffix") || "";
@@ -22,6 +22,15 @@ export const serverUrl = core.getInput("server-url");
export const githubToken = core.getInput("github-token");
export const manifestFile = getManifestFile();
function getVersionFile(): string {
const versionFileInput = core.getInput("version-file");
if (versionFileInput !== "") {
const tildeExpanded = expandTilde(versionFileInput);
return resolveRelativePath(tildeExpanded);
}
return versionFileInput;
}
function getEnableCache(): boolean {
const enableCacheInput = core.getInput("enable-cache");
if (enableCacheInput === "auto") {
@@ -108,7 +117,11 @@ function resolveRelativePath(inputPath: string): string {
if (path.isAbsolute(inputPath)) {
return inputPath;
}
const absolutePath = `${workingDirectory}${path.sep}${inputPath}`;
let absolutePath = inputPath;
if (absolutePath.startsWith("./")) {
absolutePath = absolutePath.substring(2);
}
absolutePath = `${workingDirectory}${path.sep}${absolutePath}`;
core.debug(`Resolving relative path ${inputPath} to ${absolutePath}`);
return absolutePath;
}