MCPcopy Index your code
hub / github.com/github/docs / prependDatedEntry

Function prependDatedEntry

src/graphql/scripts/build-changelog.js:14–26  ·  view source on GitHub ↗
(changelogEntry, targetPath)

Source from the content-addressed store, hash-verified

12 * @return {void}
13 */
14export function prependDatedEntry(changelogEntry, targetPath) {
15 // Build a `yyyy-mm-dd`-formatted date string
16 // and tag the changelog entry with it
17 const todayString = new Date().toISOString().slice(0, 10)
18 changelogEntry.date = todayString
19
20 const previousChangelogString = fs.readFileSync(targetPath)
21 const previousChangelog = JSON.parse(previousChangelogString)
22 // add a new entry to the changelog data
23 previousChangelog.unshift(changelogEntry)
24 // rewrite the updated changelog
25 fs.writeFileSync(targetPath, JSON.stringify(previousChangelog, null, 2))
26}
27
28/**
29 * Compare `oldSchemaString` to `newSchemaString`, and if there are any

Callers 2

mainFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected