generated from obsidianmd/obsidian-sample-plugin
-
-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
42 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { readFileSync, writeFile } from "fs"; | ||
|
||
import { Command } from "commander"; | ||
const program = new Command(); | ||
|
||
program.option("-b, --beta", "Pre-release version"); | ||
|
||
program.parse(); | ||
const opt = program.opts(); | ||
|
||
/** | ||
* Remove text from the file | ||
* @param {string} path | ||
*/ | ||
function removeText(path) { | ||
const toRemove = [ | ||
"# Changelog", | ||
"All notable changes to this project will be documented in this file. See [commit-and-tag-version](https://github.com/absolute-version/commit-and-tag-version) for commit guidelines.", | ||
]; | ||
let changelog = readFileSync(path, "utf8"); | ||
for (const remove of toRemove) changelog = changelog.replace(remove, "").trim(); | ||
changelog = changelog.replaceAll(/[\n\r]{3,}/gm, "\n\n").trim(); | ||
changelog = changelog.replaceAll(/## (.*)[\n\r]{2}### /gm, "## $1\n### ").trim(); | ||
writeFile(path, changelog.trim(), "utf8", (err) => { | ||
if (err) return console.error(err); | ||
}); | ||
} | ||
|
||
if (!opt.beta) removeText("CHANGELOG.md"); | ||
else removeText("CHANGELOG-beta.md"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters