Replace toml parsing library (#32)

"toml" does not support all TOML features
https://github.com/BinaryMuse/toml-node/issues/51

Fixes: #31
This commit is contained in:
Kevin Stillhammer
2024-12-23 19:07:34 +01:00
committed by GitHub
parent 7a82f1f7e4
commit 31a5185046
4 changed files with 2185 additions and 4081 deletions
+7 -4
View File
@@ -1,15 +1,18 @@
import * as fs from "node:fs";
import * as core from "@actions/core";
import * as toml from "toml";
import * as toml from "@iarna/toml";
export function getRuffVersionFromPyproject(
filePath: string,
): string | undefined {
const pyprojectContent = fs.readFileSync(filePath, "utf-8");
const pyproject = toml.parse(pyprojectContent);
const pyproject = toml.parse(pyprojectContent) as {
project?: { dependencies?: string[] };
"dependency-groups"?: { dev?: string[] };
};
const dependencies: string[] = pyproject.project?.dependencies || [];
const devDependencies: string[] = pyproject["dependency-groups"]?.dev || [];
const dependencies: string[] = pyproject?.project?.dependencies || [];
const devDependencies: string[] = pyproject?.["dependency-groups"]?.dev || [];
const ruffVersionDefinition =
dependencies.find((dep: string) => dep.startsWith("ruff")) ||