mirror of
https://github.com/awalsh128/cache-apt-pkgs-action.git
synced 2026-07-06 09:04:38 +00:00
docs: add examples in manifest module
This commit is contained in:
parent
28500b4b3f
commit
7c095b09cb
|
|
@ -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 "";
|
||||
|
|
|
|||
Loading…
Reference in a new issue