-
-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🎨 Hide the changelog preset beneath a scripts folder + rewrite
- Loading branch information
Showing
10 changed files
with
75 additions
and
75 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
test/* linguist-vendored | ||
conventional-changelog-wretch/* linguist-vendored | ||
scripts/* linguist-vendored |
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 was deleted.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,68 @@ | ||
const resolve = require("path").resolve | ||
const Q = require("q") | ||
const readFile = Q.denodeify(require("fs").readFile) | ||
|
||
const emojiMatch = { | ||
":fire:": "Breaking change(s)", | ||
":bug:": "Bug fix(es)", | ||
":factory:": "New feature(s)", | ||
":art:": "Code improvement(s)", | ||
":checkered_flag:": "Performance update(s)", | ||
":white_check_mark:": "Test improvement(s)", | ||
":memo:": "Documentation update(s)", | ||
":arrow_up:": "Version update(s)" | ||
} | ||
|
||
function presetOpts(cb) { | ||
|
||
const parserOpts = { | ||
headerPattern: /^(:.*?:) (.*)$/, | ||
headerCorrespondence: [ | ||
"emoji", | ||
"shortDesc" | ||
] | ||
} | ||
|
||
const writerOpts = { | ||
transform: function (commit) { | ||
if (!commit.emoji || typeof commit.emoji !== "string") | ||
return | ||
|
||
const emojiText = emojiMatch[commit.emoji]; | ||
commit.emoji = commit.emoji.substring(0, 72); | ||
const emojiLength = commit.emoji.length; | ||
|
||
if (typeof commit.hash === 'string') { | ||
commit.hash = commit.hash.substring(0, 7); | ||
} | ||
|
||
if (typeof commit.shortDesc === 'string') { | ||
commit.shortDesc = commit.shortDesc.substring(0, 72 - emojiLength); | ||
} | ||
|
||
commit.emoji = commit.emoji + " " + emojiText | ||
|
||
return commit | ||
}, | ||
groupBy: "emoji", | ||
commitGroupsSort: "title", | ||
commitsSort: ["emoji", "shortDesc"] | ||
} | ||
|
||
Q.all([ | ||
readFile(resolve(__dirname, "templates/template.hbs"), "utf-8"), | ||
readFile(resolve(__dirname, "templates/header.hbs"), "utf-8"), | ||
readFile(resolve(__dirname, "templates/commit.hbs"), "utf-8") | ||
]).spread(function(template, header, commit) { | ||
writerOpts.mainTemplate = template | ||
writerOpts.headerPartial = header | ||
writerOpts.commitPartial = commit | ||
|
||
cb(null, { | ||
parserOpts: parserOpts, | ||
writerOpts: writerOpts | ||
}) | ||
}) | ||
} | ||
|
||
module.exports = presetOpts |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.