Skip to content

Commit

Permalink
🎨 Hide the changelog preset beneath a scripts folder + rewrite
Browse files Browse the repository at this point in the history
  • Loading branch information
elbywan committed Oct 4, 2017
1 parent 0883134 commit 696503c
Show file tree
Hide file tree
Showing 10 changed files with 75 additions and 75 deletions.
2 changes: 1 addition & 1 deletion .gitattributes
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
## [0.2.2](https://github.com/elbywan/wretch/compare/0.2.1...0.2.2) (2017-10-04)


### :arrow_up: Version update(s)

* 0.2.2 tag ([0883134](https://github.com/elbywan/wretch/commit/0883134))

### :art: Code improvement(s)

* Moves polyfills to the config object ([2820e34](https://github.com/elbywan/wretch/commit/2820e34))
Expand Down
72 changes: 0 additions & 72 deletions conventional-changelog-wretch/index.js

This file was deleted.

2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"devDependencies": {
"chai": "^4.1.2",
"conventional-changelog-cli": "^1.3.3",
"conventional-changelog-wretch": "file:conventional-changelog-wretch",
"conventional-changelog-wretch": "file:scripts/conventional-changelog-wretch",
"coveralls": "^2.13.1",
"form-data": "^2.3.1",
"mocha": "^3.5.3",
Expand Down
68 changes: 68 additions & 0 deletions scripts/conventional-changelog-wretch/index.js
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.

0 comments on commit 696503c

Please sign in to comment.