Skip to content

Commit

Permalink
Extract _prependChangelog() method
Browse files Browse the repository at this point in the history
  • Loading branch information
Turbo87 committed Oct 29, 2020
1 parent fd1a5b8 commit fc865f3
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,14 +163,19 @@ module.exports = class LernaChangelogGeneratorPlugin extends Plugin {
this.log.log(`! Prepending ${infile} with release notes.`);
} else {
let currentFileData = hasInfile ? fs.readFileSync(infile, { encoding: 'utf8' }) : '';
fs.writeFileSync(infile, changelog + EOL + EOL + currentFileData, { encoding: 'utf8' });
let newContent = this._insertContent(changelog, currentFileData);
fs.writeFileSync(infile, newContent, { encoding: 'utf8' });
}

if (!hasInfile) {
await this.exec(`git add ${infile}`);
}
}

_insertContent(newContent, oldContent) {
return newContent + EOL + EOL + oldContent;
}

async beforeRelease() {
let processedChangelog = await this.processChangelog();

Expand Down

0 comments on commit fc865f3

Please sign in to comment.