mirror of
https://github.com/astral-sh/ruff-action.git
synced 2026-05-19 15:30:14 +02:00
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:
committed by
GitHub
parent
7a82f1f7e4
commit
31a5185046
@@ -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")) ||
|
||||
|
||||
Reference in New Issue
Block a user