Skip to content

Commit

Permalink
chore: skip changelog rewrite if changelog doesn't exist
Browse files Browse the repository at this point in the history
  • Loading branch information
pieh committed May 24, 2022
1 parent fb4de37 commit 791071f
Showing 1 changed file with 23 additions and 11 deletions.
34 changes: 23 additions & 11 deletions scripts/gatsby-changelog-generator/generate.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,17 +232,29 @@ async function regenerateChangelog(packageName) {
}

function addChangelogEntries(packageName, entries, contents) {
contents = contents || String(fs.readFileSync(changelogPath(packageName)))
const header = renderHeader(packageName)
const updatedChangelogParts = [
header,
entries.trimRight(),
contents.slice(header.length).trimStart(),
]
fs.writeFileSync(
changelogPath(packageName),
updatedChangelogParts.join(`\n\n`)
)
try {
contents = contents || String(fs.readFileSync(changelogPath(packageName)))
const header = renderHeader(packageName)
const updatedChangelogParts = [
header,
entries.trimRight(),
contents.slice(header.length).trimStart(),
]
fs.writeFileSync(
changelogPath(packageName),
updatedChangelogParts.join(`\n\n`)
)
} catch (e) {
/*
We don't have changelog file, so we skip it
package "gatsby-parcel-config": Error: ENOENT: no such file or directory, open '/Users/misiek/dev/pgs-gatsby/packages/gatsby-parcel-config/CHANGELOG.md'
at Object.openSync (fs.js:498:3)
at Object.readFileSync (fs.js:394:35)
at addChangelogEntries (/Users/misiek/dev/pgs-gatsby/scripts/gatsby-changelog-generator/generate.js:235:36)
at onNewVersion (/Users/misiek/dev/pgs-gatsby/scripts/gatsby-changelog-generator/generate.js:314:9)
*/
console.error(e)
}
}

/**
Expand Down

0 comments on commit 791071f

Please sign in to comment.