@alcalzone/release-script-plugin-changelog
Advanced tools
Comparing version 3.4.0 to 3.4.1
@@ -133,2 +133,3 @@ "use strict"; | ||
const parsed = parseChangelogFile(changelog, changelogPlaceholderPrefix); | ||
const changelogHasFinalNewline = changelog.replace(/(\r|\n|\r\n)/g, "\n").endsWith("\n"); | ||
let parsedOld; | ||
@@ -142,2 +143,3 @@ if (changelogOld) { | ||
context.setData("changelog_after", parsed.after); | ||
context.setData("changelog_final_newline", changelogHasFinalNewline); | ||
context.setData("changelog_location", changelogLocation); | ||
@@ -148,2 +150,6 @@ context.setData("changelog_entry_prefix", changelogPlaceholderPrefix); | ||
context.setData("changelog_old_after", parsedOld.after); | ||
const changelogOldHasFinalNewline = changelogOld | ||
.replace(/(\r|\n|\r\n)/g, "\n") | ||
.endsWith("\n"); | ||
context.setData("changelog_old_final_newline", changelogOldHasFinalNewline); | ||
} | ||
@@ -195,5 +201,8 @@ // check if the changelog contains exactly 1 occurence of the changelog placeholder | ||
const changelogAfter = context.getData("changelog_after").trimStart(); | ||
const changelogHasFinalNewline = context.getData("changelog_final_newline"); | ||
const prefix = context.getData("changelog_entry_prefix"); | ||
const newVersion = context.getData("version_new"); | ||
const hasChangelogOld = context.hasData("changelog_old_before") && context.hasData("changelog_old_after"); | ||
const changelogOldHasFinalNewline = context.hasData("changelog_old_final_newline") && | ||
context.getData("changelog_old_final_newline"); | ||
// Replace the changelog placeholder and keep the free text | ||
@@ -215,5 +224,7 @@ const placeholderRegex = buildChangelogPlaceholderRegex(prefix)(); | ||
context.cli.log(`Updating changelog in ${changelogFilename}`); | ||
await fs_extra_1.default.writeFile(path_1.default.join(context.cwd, changelogFilename), (changelogBefore + "\n" + entriesNew.join("") + changelogAfter).trim()); | ||
await fs_extra_1.default.writeFile(path_1.default.join(context.cwd, changelogFilename), (changelogBefore + "\n" + entriesNew.join("") + changelogAfter).trim() + | ||
(changelogHasFinalNewline ? "\n" : "")); | ||
context.cli.log(`Updating changelog in CHANGELOG_OLD.md`); | ||
await fs_extra_1.default.writeFile(path_1.default.join(context.cwd, "CHANGELOG_OLD.md"), (changelogOldBefore + "\n" + entriesOld.join("") + changelogOldAfter).trim()); | ||
await fs_extra_1.default.writeFile(path_1.default.join(context.cwd, "CHANGELOG_OLD.md"), (changelogOldBefore + "\n" + entriesOld.join("") + changelogOldAfter).trim() + | ||
(changelogOldHasFinalNewline ? "\n" : "")); | ||
} | ||
@@ -225,3 +236,4 @@ else { | ||
context.cli.log(`Updating changelog in ${changelogFilename}`); | ||
await fs_extra_1.default.writeFile(path_1.default.join(context.cwd, changelogFilename), (changelogBefore + "\n" + normalizedEntries.join("") + changelogAfter).trim()); | ||
await fs_extra_1.default.writeFile(path_1.default.join(context.cwd, changelogFilename), (changelogBefore + "\n" + normalizedEntries.join("") + changelogAfter).trim() + | ||
(changelogHasFinalNewline ? "\n" : "")); | ||
} | ||
@@ -228,0 +240,0 @@ } |
@@ -6,3 +6,3 @@ { | ||
}, | ||
"version": "3.4.0", | ||
"version": "3.4.1", | ||
"description": "Plugin for Al Calzone's release script: changelog", | ||
@@ -41,7 +41,7 @@ "keywords": [], | ||
"dependencies": { | ||
"@alcalzone/release-script-core": "3.3.0", | ||
"@alcalzone/release-script-core": "3.4.1", | ||
"alcalzone-shared": "^4.0.0" | ||
}, | ||
"devDependencies": { | ||
"@alcalzone/release-script-testing": "3.3.0", | ||
"@alcalzone/release-script-testing": "3.4.1", | ||
"jest-extended": "^0.11.5", | ||
@@ -64,3 +64,3 @@ "typescript": "*" | ||
"readmeFilename": "README.md", | ||
"gitHead": "14eda1be2d5db8f707723be8b0be6310553b7181" | ||
"gitHead": "304b367ce01290898f04156020789b422f4ba83b" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
28730
288
+ Added@alcalzone/release-script-core@3.4.1(transitive)
- Removed@alcalzone/release-script-core@3.3.0(transitive)