mirror of
https://github.com/astral-sh/setup-uv.git
synced 2026-02-25 18:04:58 +00:00
26 lines
685 B
TypeScript
26 lines
685 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> {
|
|
await fs.rm(filePath);
|
|
await fs.appendFile(
|
|
filePath,
|
|
"// AUTOGENERATED_DO_NOT_EDIT\nexport const KNOWN_CHECKSUMS: { [key: string]: string } = {\n",
|
|
);
|
|
let firstLine = true;
|
|
for (const entry of checksumEntries) {
|
|
if (!firstLine) {
|
|
await fs.appendFile(filePath, ",\n");
|
|
}
|
|
await fs.appendFile(filePath, ` "${entry.key}":\n "${entry.checksum}"`);
|
|
firstLine = false;
|
|
}
|
|
await fs.appendFile(filePath, ",\n};\n");
|
|
}
|