Skip to content

Commit

Permalink
match release-plan test for Changelog header
Browse files Browse the repository at this point in the history
  • Loading branch information
mansona committed Jan 22, 2024
1 parent e6a3ee1 commit bd4e3b8
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 258 deletions.
11 changes: 4 additions & 7 deletions bin/release-plan-setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import util from 'util';
import { execa } from 'execa';
import sortPackageJson from 'sort-package-json';
import gitconfiglocal from 'gitconfiglocal';
import { fromMarkdown } from 'mdast-util-from-markdown';
import findRepoURL from '../lib/findRepoUrl.js';
import getDependencyRange from '../lib/getDependencyRange.js';
import ejs from 'ejs';
Expand Down Expand Up @@ -158,13 +157,11 @@ try {
}

if (hasChangelog && !labelsOnly) {
let changelogContent = fs.readFileSync('CHANGELOG.md', { encoding: 'utf8' });
let ast = fromMarkdown(changelogContent);
let changelogContent = fs.readFileSync('CHANGELOG.md', { encoding: 'utf8' }).split('\n');
const changelogPreamblePattern = /#.*Changelog.*$/;

let hasH1 = ast.children.find((it) => it.type === 'heading' && it.depth === 1);

if (!hasH1) {
fs.writeFileSync('CHANGELOG.md', `# Changelog\n\n${changelogContent}`, {
if (!changelogPreamblePattern.test(changelogContent[0])) {
fs.writeFileSync('CHANGELOG.md', `# Changelog\n\n${changelogContent.join('\n')}`, {
encoding: 'utf8',
});
}
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
"github-label-sync": "^2.3.1",
"hosted-git-info": "^7.0.1",
"lodash.template": "^4.5.0",
"mdast-util-from-markdown": "^2.0.0",
"semver": "^7.3.5",
"sort-package-json": "^2.6.0",
"which": "^4.0.0"
Expand Down
252 changes: 2 additions & 250 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit bd4e3b8

Please sign in to comment.