3
0
Fork 0
mirror of https://github.com/Swatinem/rust-cache synced 2025-04-29 06:35:53 +00:00

dep: Use smol-toml instead of toml (#164)

Fixed #162 #163

The former is listed on
https://github.com/toml-lang/toml/wiki#implementations and is toml 1.0
compliant.

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
Jiahao XU 2023-08-19 20:23:03 +10:00 committed by GitHub
parent 578b235f6e
commit ab6b2769d1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 1921 additions and 8154 deletions

View file

@ -5,7 +5,7 @@ import fs from "fs";
import fs_promises from "fs/promises";
import os from "os";
import path from "path";
import * as toml from "toml";
import * as toml from "smol-toml";
import { getCargoBins } from "./cleanup";
import { CacheProvider, getCmdOutput } from "./utils";
@ -147,12 +147,13 @@ export class CacheConfig {
for (const cargo_manifest of cargo_manifests) {
try {
const content = await fs_promises.readFile(cargo_manifest, { encoding: "utf8" });
const parsed = toml.parse(content);
// Use any since TomlPrimitive is not exposed
const parsed = toml.parse(content) as { [key: string]: any };
if ("package" in parsed) {
const pack = parsed.package;
if ("version" in pack) {
pack.version = "0.0.0";
pack["version"] = "0.0.0";
}
}
@ -205,7 +206,7 @@ export class CacheConfig {
// Package without `[[package]].source` and `[[package]].checksum`
// are the one with `path = "..."` to crates within the workspace.
const packages = parsed.package.filter((p: any) => "source" in p || "checksum" in p);
const packages = (parsed.package as any[]).filter((p: any) => "source" in p || "checksum" in p);
hasher.update(JSON.stringify(packages));