diff --git a/dist/index.js b/dist/index.js index f756abb..467b8aa 100644 --- a/dist/index.js +++ b/dist/index.js @@ -11549,13 +11549,17 @@ function getWorkingDirectory() { } return workdir; } +function parseTOMLNormalized(input) { + const normalized = input.replace(/\r\n$/g, '\n'); + return (0, toml_1.parse)(normalized); +} function getManifestDir(args) { const workdir = getWorkingDirectory(); const manifestPath = getCliValue(args, '--manifest-path') || getCliValue(args, '-m'); return manifestPath ? path.dirname(path.join(workdir, manifestPath)) : workdir; } function parseRustToolchain(content) { - const toml = (0, toml_1.parse)(content.toString()); + const toml = parseTOMLNormalized(content.toString()); const toolchain = toml === null || toml === void 0 ? void 0 : toml.toolchain; return (toolchain === null || toolchain === void 0 ? void 0 : toolchain.channel) || ''; } @@ -11650,7 +11654,7 @@ async function findVersion(args) { const pyprojectToml = path.join(manifestDir, 'pyproject.toml'); if ((0, fs_1.existsSync)(pyprojectToml)) { const content = await fs_1.promises.readFile(pyprojectToml); - const toml = (0, toml_1.parse)(content.toString()); + const toml = parseTOMLNormalized(content.toString()); const buildSystem = (toml['build-system'] || {}); const requires = (buildSystem['requires'] || []); const maturin = requires.find(req => req.startsWith('maturin')); diff --git a/src/index.ts b/src/index.ts index eb69db0..ab4992e 100644 --- a/src/index.ts +++ b/src/index.ts @@ -221,6 +221,12 @@ function getWorkingDirectory(): string { return workdir } +function parseTOMLNormalized(input: string): JsonMap { + // Normalize CRLF to LF to avoid hitting https://github.com/iarna/iarna-toml/issues/33 + const normalized = input.replace(/\r\n$/g, '\n') + return parseTOML(normalized) +} + function getManifestDir(args: string[]): string { const workdir = getWorkingDirectory() const manifestPath = @@ -229,7 +235,7 @@ function getManifestDir(args: string[]): string { } function parseRustToolchain(content: string): string { - const toml = parseTOML(content.toString()) + const toml = parseTOMLNormalized(content.toString()) const toolchain = toml?.toolchain as JsonMap return (toolchain?.channel as string) || '' } @@ -356,7 +362,7 @@ async function findVersion(args: string[]): Promise { const pyprojectToml = path.join(manifestDir, 'pyproject.toml') if (existsSync(pyprojectToml)) { const content = await fs.readFile(pyprojectToml) - const toml = parseTOML(content.toString()) + const toml = parseTOMLNormalized(content.toString()) const buildSystem = (toml['build-system'] || {}) as JsonMap const requires = (buildSystem['requires'] || []) as string[] const maturin = requires.find(req => req.startsWith('maturin'))