mirror of
https://github.com/astral-sh/setup-uv.git
synced 2026-04-17 02:06:29 +00:00
Refactor version resolving (#852)
This commit is contained in:
committed by
GitHub
parent
cb84d12dc6
commit
cdfb2ee6dd
@@ -8,7 +8,19 @@ export function getConfigValueFromTomlFile(
|
||||
if (!fs.existsSync(filePath) || !filePath.endsWith(".toml")) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const fileContent = fs.readFileSync(filePath, "utf-8");
|
||||
return getConfigValueFromTomlContent(filePath, fileContent, key);
|
||||
}
|
||||
|
||||
export function getConfigValueFromTomlContent(
|
||||
filePath: string,
|
||||
fileContent: string,
|
||||
key: string,
|
||||
): string | undefined {
|
||||
if (!filePath.endsWith(".toml")) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
if (filePath.endsWith("pyproject.toml")) {
|
||||
const tomlContent = toml.parse(fileContent) as {
|
||||
@@ -16,6 +28,7 @@ export function getConfigValueFromTomlFile(
|
||||
};
|
||||
return tomlContent?.tool?.uv?.[key];
|
||||
}
|
||||
|
||||
const tomlContent = toml.parse(fileContent) as Record<
|
||||
string,
|
||||
string | undefined
|
||||
|
||||
Reference in New Issue
Block a user