mirror of
https://github.com/astral-sh/setup-uv.git
synced 2026-04-16 16:40:17 +00:00
chore: normalize venv-path and warn when unused
- Normalize venv-path and trim trailing separators - Improve activation log message - Warn when venv-path is set without activate-environment - Add test coverage for trailing slash + warning
This commit is contained in:
parent
4b51b416f8
commit
45fe5a27c5
5 changed files with 84 additions and 8 deletions
17
dist/save-cache/index.js
generated
vendored
17
dist/save-cache/index.js
generated
vendored
|
|
@ -91079,10 +91079,13 @@ function getVersionFile() {
|
|||
function getVenvPath() {
|
||||
const venvPathInput = core.getInput("venv-path");
|
||||
if (venvPathInput !== "") {
|
||||
if (!exports.activateEnvironment) {
|
||||
core.warning("venv-path is only used when activate-environment is true");
|
||||
}
|
||||
const tildeExpanded = expandTilde(venvPathInput);
|
||||
return resolveRelativePath(tildeExpanded);
|
||||
return normalizePath(resolveRelativePath(tildeExpanded));
|
||||
}
|
||||
return resolveRelativePath(".venv");
|
||||
return normalizePath(resolveRelativePath(".venv"));
|
||||
}
|
||||
function getEnableCache() {
|
||||
const enableCacheInput = core.getInput("enable-cache");
|
||||
|
|
@ -91212,6 +91215,16 @@ function expandTilde(input) {
|
|||
}
|
||||
return input;
|
||||
}
|
||||
function normalizePath(inputPath) {
|
||||
const normalized = node_path_1.default.normalize(inputPath);
|
||||
const root = node_path_1.default.parse(normalized).root;
|
||||
// Remove any trailing path separators, except when the whole path is the root.
|
||||
let trimmed = normalized;
|
||||
while (trimmed.length > root.length && trimmed.endsWith(node_path_1.default.sep)) {
|
||||
trimmed = trimmed.slice(0, -1);
|
||||
}
|
||||
return trimmed;
|
||||
}
|
||||
function resolveRelativePath(inputPath) {
|
||||
const hasNegation = inputPath.startsWith("!");
|
||||
const pathWithoutNegation = hasNegation ? inputPath.substring(1) : inputPath;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue