docs: add examples in manifest module

This commit is contained in:
Andrew Walsh 2026-07-04 11:24:58 -07:00
parent 28500b4b3f
commit 7c095b09cb

View file

@ -1,5 +1,15 @@
import fs from "node:fs";
/**
* Writes manifest entries as newline-delimited, sorted values.
*
* @param filePath Output manifest path.
* @param entries Manifest entries to normalize and write.
* @returns Nothing.
*
* @example
* writeManifest("/tmp/manifest.log", ["git=2.39", "curl=8.5.0"]);
*/
export function writeManifest(filePath: string, entries: string[]): void {
const normalized = [...entries]
.filter(Boolean)
@ -7,6 +17,15 @@ export function writeManifest(filePath: string, entries: string[]): void {
fs.writeFileSync(filePath, normalized.join("\n"), "utf8");
}
/**
* Reads a newline-delimited manifest and returns a CSV string.
*
* @param filePath Input manifest path.
* @returns Comma-separated manifest entries or an empty string when missing.
*
* @example
* const csv = readManifestAsCsv("/tmp/manifest.log");
*/
export function readManifestAsCsv(filePath: string): string {
if (!fs.existsSync(filePath)) {
return "";