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

Function appendLinkRef

scripts/prepare-release.mjs:253–263  ·  view source on GitHub ↗

* Append a `[X.Y.Z]: https://github.com/colbymchenry/codegraph/releases/tag/vX.Y.Z` * link reference at the end of the file IF one doesn't already exist. The * link ref is what makes `## [X.Y.Z]` heading text auto-link to its tag in * GitHub's renderer; without it the heading still renders, just

(text, version)

Source from the content-addressed store, hash-verified

251 * which CommonMark accepts regardless.
252 */
253function appendLinkRef(text, version) {
254 const refLine = `[${version}]: https://github.com/colbymchenry/codegraph/releases/tag/v${version}`;
255 // Already there? Look for a line that EQUALS this (anywhere in the file)
256 // to keep idempotency robust against the scattered-vs-block layout.
257 const lines = text.split('\n');
258 if (lines.some((l) => l.trim() === refLine)) return text;
259 // Append, separated by a blank line from the prior content. Preserve a
260 // single trailing newline at EOF.
261 const trailingNewline = text.endsWith('\n') ? '' : '\n';
262 return text + trailingNewline + refLine + '\n';
263}
264
265try {
266 main();

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected