Skip to content

Commit

Permalink
Add support for auto-determing different CHANGELOG filenames (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
koppor authored and MoOx committed Dec 6, 2017
1 parent cf50e4e commit eb8f208
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions github-release-from-changelog.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,26 @@ var cp = require('child_process');
var minimist = require('minimist');
var argv = minimist(process.argv.slice(2));

var fs = require("fs")

// changelog file name
var changelogFileName = argv.filename || "CHANGELOG.md";
var changelogFileName = argv.filename;
if (!changelogFileName) {
const changelogFileNames = [
"CHANGELOG.md", "Changelog.md", "changelog.md",
"CHANGES.md", "Changes.md", "changes.md",
"HISTORY.md", "History.md", "history.md",
"NEWS.md", "News.md", "news.md",
"RELEASES.md", "Releases.md", "releases.md"
];
for (var fileName of changelogFileNames) {
if (fs.existsSync(fileName)) {
changelogFileName = fileName;
break;
}
}
}
// console.log("changelog filename", changelogFileName);

// get dep
var release = require("grizzly")
Expand All @@ -42,7 +60,7 @@ catch(e) {throw "No package.json found in " + process.cwd()}
// read changelog
var changelog
try {
changelog = require("fs").readFileSync(process.cwd() + "/" + changelogFileName, {encoding: "utf8"})
changelog = fs.readFileSync(process.cwd() + "/" + changelogFileName, {encoding: "utf8"})
}
catch(e) {throw "No " + changelogFileName + " found in " + process.cwd()}

Expand Down

0 comments on commit eb8f208

Please sign in to comment.