3
0
Fork 0
mirror of https://github.com/Swatinem/rust-cache synced 2025-06-22 16:23:42 +00:00

Only key by Cargo.toml and Cargo.lock files of workspace members (#180)

This commit is contained in:
Max Heller 2023-12-03 05:57:51 -05:00 committed by GitHub
parent b1db5f9d5f
commit d30f1144e8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 88 additions and 62 deletions

View file

@ -8,7 +8,7 @@ import path from "path";
import * as toml from "smol-toml";
import { getCargoBins } from "./cleanup";
import { CacheProvider, getCmdOutput } from "./utils";
import { CacheProvider, exists, getCmdOutput } from "./utils";
import { Workspace } from "./workspace";
const HOME = os.homedir();
@ -142,7 +142,9 @@ export class CacheConfig {
)),
);
const cargo_manifests = sort_and_uniq(await globFiles(`${root}/**/Cargo.toml`));
const workspaceMembers = await workspace.getWorkspaceMembers();
const cargo_manifests = sort_and_uniq(workspaceMembers.map(member => path.join(member.path, "Cargo.toml")));
for (const cargo_manifest of cargo_manifests) {
try {
@ -189,9 +191,8 @@ export class CacheConfig {
}
}
const cargo_locks = sort_and_uniq(await globFiles(`${root}/**/Cargo.lock`));
for (const cargo_lock of cargo_locks) {
const cargo_lock = path.join(workspace.root, "Cargo.lock");
if (await exists(cargo_lock)) {
try {
const content = await fs_promises.readFile(cargo_lock, { encoding: "utf8" });
const parsed = toml.parse(content);