MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / removeTomlTable

Function removeTomlTable

src/installer/targets/toml.ts:109–122  ·  view source on GitHub ↗
(
  fileContent: string,
  header: string,
)

Source from the content-addressed store, hash-verified

107 * possibly-empty new content + an action flag.
108 */
109export function removeTomlTable(
110 fileContent: string,
111 header: string,
112): { content: string; action: 'removed' | 'not-found' } {
113 const headerLine = `[${header}]`;
114 const headerIdx = findHeaderIndex(fileContent, headerLine);
115 if (headerIdx === -1) return { content: fileContent, action: 'not-found' };
116
117 const blockEnd = findNextTableHeader(fileContent, headerIdx + headerLine.length);
118 const before = fileContent.substring(0, headerIdx).replace(/\n+$/, '');
119 const after = fileContent.substring(blockEnd).replace(/^\n+/, '');
120 const joined = before + (before && after ? '\n\n' : '') + after;
121 return { content: joined, action: 'removed' };
122}
123
124/**
125 * Locate the byte index of a header line (`[foo.bar]`) when it

Callers 2

uninstallMethod · 0.90

Calls 2

findHeaderIndexFunction · 0.85
findNextTableHeaderFunction · 0.85

Tested by

no test coverage detected