mirror of
https://github.com/astral-sh/setup-uv.git
synced 2026-10-02 00:35:59 +00:00
26 lines
592 B
TypeScript
26 lines
592 B
TypeScript
import { promises as fs } from "node:fs";
|
|
|
|
export interface ChecksumEntry {
|
|
key: string;
|
|
checksum: string;
|
|
}
|
|
|
|
export async function updateChecksums(
|
|
filePath: string,
|
|
checksumEntries: ChecksumEntry[],
|
|
): Promise<void> {
|
|
const deduplicatedEntries = new Map<string, string>();
|
|
|
|
for (const entry of checksumEntries) {
|
|
if (deduplicatedEntries.has(entry.key)) {
|
|
continue;
|
|
}
|
|
|
|
deduplicatedEntries.set(entry.key, entry.checksum);
|
|
}
|
|
|
|
const content = `${JSON.stringify(Object.fromEntries(deduplicatedEntries), null, 2)}\n`;
|
|
|
|
await fs.writeFile(filePath, content);
|
|
}
|