MCPcopy Create free account
hub / github.com/dmno-dev/bumpy / updateJsonFields

Function updateJsonFields

packages/bumpy/src/utils/fs.ts:23–31  ·  view source on GitHub ↗
(filePath: string, updates: Record<string, string>)

Source from the content-addressed store, hash-verified

21 * Reads the raw text, does targeted regex replacements, and writes it back.
22 */
23export async function updateJsonFields(filePath: string, updates: Record<string, string>): Promise<void> {
24 let content = await readFile(filePath, 'utf-8');
25 for (const [key, newValue] of Object.entries(updates)) {
26 const escaped = key.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
27 const pattern = new RegExp(`("${escaped}"\\s*:\\s*)"[^"]*"`);
28 content = content.replace(pattern, `$1"${newValue}"`);
29 }
30 await writeFile(filePath, content, 'utf-8');
31}
32
33/**
34 * Update a nested string field inside a top-level object in a JSON file without reformatting.

Callers 2

applyReleasePlanFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…