Don’t include skins in default categories

release
Etienne Lemay 2016-05-31 16:42:22 -04:00
parent fed3733eb4
commit 2820e80fc0
1 changed files with 12 additions and 6 deletions

View File

@ -3,8 +3,8 @@ var emojiData = require('emoji-data')
var inflection = require('inflection')
var mkdirp = require('mkdirp')
var categories = ['People', 'Nature', 'Foods', 'Activity', 'Places', 'Objects', 'Symbols', 'Flags', 'Skins']
var data = { categories: [], emojis: {} }
var categories = ['People', 'Nature', 'Foods', 'Activity', 'Places', 'Objects', 'Symbols', 'Flags']
var data = { categories: [], emojis: {}, skins: {} }
var categoriesIndex = {}
categories.forEach((category, i) => {
@ -28,9 +28,11 @@ emojiData.forEach((datum) => {
if (/^skin/.test(shortName)) category = 'Skins'
if (/^flag/.test(shortName)) category = 'Flags'
if (/^(left_speech_bubble|keycap_star|eject)$/.test(shortName)) category = 'Symbols'
datum.category = category
}
if (!category) {
if (!datum.category) {
throw new Error('“' + datum.short_name + '” doesnt have a category')
}
@ -41,9 +43,13 @@ emojiData.forEach((datum) => {
throw new Error('“' + datum.short_name + '” doesnt have a name')
}
if (datum.category == 'Skins') {
data.skins[datum.short_name] = datum
} else {
categoryIndex = categoriesIndex[category]
data.categories[categoryIndex].emojis.push(datum.short_name)
data.emojis[datum.short_name] = datum
}
})
mkdirp('data', (err) => {