Skip to content

Commit

Permalink
🐛 Fix emojies not identified in some commits (#65)
Browse files Browse the repository at this point in the history
  • Loading branch information
bpetetot authored and frinyvonnick committed Oct 31, 2018
1 parent afa7021 commit 6a3b1b6
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 886 deletions.
1 change: 1 addition & 0 deletions packages/gitmoji-changelog-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"git-remote-origin-url": "^2.0.0",
"git-semver-tags": "^2.0.0",
"lodash": "^4.17.11",
"node-emoji": "^1.8.1",
"normalize-package-data": "^2.4.0",
"read-pkg-up": "^4.0.0",
"semver": "^5.6.0",
Expand Down
65 changes: 0 additions & 65 deletions packages/gitmoji-changelog-core/src/emojiMapping.js

This file was deleted.

31 changes: 13 additions & 18 deletions packages/gitmoji-changelog-core/src/parser.js
Original file line number Diff line number Diff line change
@@ -1,33 +1,28 @@
const splitLines = require('split-lines')
const { invert } = require('lodash')
const nodeEmoji = require('node-emoji')
const groupMapping = require('./groupMapping')
const emojiMapping = require('./emojiMapping')

const emojiMappingInvert = invert(emojiMapping)

function parseSubject(subject) {
if (!subject) return {}

let emojiCode
let message = subject
const unemojified = nodeEmoji.unemojify(subject)

const matches = unemojified.match(/:(\w*):(.*)/)

const matches = subject.match(/:(\w*):(.*)/)
if (matches) {
// extract textual emoji
[, emojiCode, message] = matches
} else {
// extract unicode emoji
const emoji = subject.substr(0, 1)
emojiCode = emojiMappingInvert[emoji]
if (emojiCode) {
message = subject.substr(1, subject.length)
const [, emojiCode, message] = matches

if (nodeEmoji.hasEmoji(emojiCode)) {
return {
emojiCode,
emoji: nodeEmoji.get(emojiCode),
message: nodeEmoji.emojify(message.trim()),
}
}
}

return {
emojiCode,
emoji: emojiMapping[emojiCode] || '¿',
message: message.trim(),
message: subject,
}
}

Expand Down
Loading

0 comments on commit 6a3b1b6

Please sign in to comment.