Skip to content

Commit

Permalink
Unified header line break identifier (#44)
Browse files Browse the repository at this point in the history
  • Loading branch information
lpreterite authored and webpro committed Mar 9, 2022
1 parent 4169980 commit a71b286
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,9 @@ class ConventionalChangelog extends Plugin {
}

async writeChangelog() {
const { infile, header } = this.options;
const { infile, header: _header } = this.options;
let { changelog } = this.config.getContext();
const header = _header.split(/\r\n|\r|\n/g).join(EOL);

let hasInfile = false;
try {
Expand All @@ -115,7 +116,7 @@ class ConventionalChangelog extends Plugin {
let previousChangelog = '';
try {
previousChangelog = await this.getPreviousChangelog();
previousChangelog = previousChangelog.replace(header.split(/\r\n|\r|\n/g).join(EOL), '');
previousChangelog = previousChangelog.replace(header, '');
} catch (err) {
this.debug(err);
}
Expand Down
2 changes: 1 addition & 1 deletion test.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ test(`should write and update infile (${infile})`, async t => {
const plugin = factory(Plugin, { namespace, options });
await runTasks(plugin);
const changelog = fs.readFileSync(infile);
assert.strictEqual(changelog.toString().trim(), `${header}${EOL}${EOL}The changelog`);
assert.strictEqual(changelog.toString().trim(), `The header${EOL}${EOL}The subheader${EOL}${EOL}The changelog`);
{
await runTasks(plugin);
const changelog = fs.readFileSync(infile);
Expand Down

0 comments on commit a71b286

Please sign in to comment.