Add tool bin dir to PATH on windows

This commit is contained in:
Kevin Stillhammer 2024-09-18 17:28:08 +02:00
parent 8205eab75b
commit 561bff6f70
No known key found for this signature in database
7 changed files with 100 additions and 5 deletions

View file

@ -18,6 +18,7 @@ import {
checkSum,
enableCache,
githubToken,
toolBinDir,
version,
} from "./utils/inputs";
@ -41,6 +42,7 @@ async function run(): Promise<void> {
);
addUvToPath(setupResult.uvDir);
addToolBinToPath();
core.setOutput("uv-version", setupResult.version);
core.info(`Successfully installed uv version ${setupResult.version}`);
@ -102,6 +104,15 @@ function addUvToPath(cachedPath: string): void {
core.info(`Added ${cachedPath} to the path`);
}
function addToolBinToPath(): void {
if (toolBinDir !== undefined) {
core.exportVariable("UV_TOOL_BIN_DIR", toolBinDir);
core.info(`Set UV_TOOL_BIN_DIR to ${toolBinDir}`);
core.addPath(toolBinDir);
core.info(`Added ${toolBinDir} to the path`);
}
}
function setCacheDir(cacheLocalPath: string): void {
core.exportVariable("UV_CACHE_DIR", cacheLocalPath);
core.info(`Set UV_CACHE_DIR to ${cacheLocalPath}`);

View file

@ -6,8 +6,20 @@ export const checkSum = core.getInput("checksum");
export const enableCache = core.getInput("enable-cache") === "true";
export const cacheSuffix = core.getInput("cache-suffix") || "";
export const cacheLocalPath = getCacheLocalPath();
export const githubToken = core.getInput("github-token");
export const cacheDependencyGlob = core.getInput("cache-dependency-glob");
export const toolBinDir = getToolBinDir();
export const githubToken = core.getInput("github-token");
function getToolBinDir(): string | undefined {
const toolBinDirInput = core.getInput("tool-bin-dir");
if (toolBinDirInput !== "") {
return toolBinDirInput;
}
if (process.platform === "win32") {
return "D:\\a\\_temp\\uv-tool-bin-dir";
}
return undefined;
}
function getCacheLocalPath(): string {
const cacheLocalPathInput = core.getInput("cache-local-path");