💄 Prettier

release
Etienne Lemay 2018-04-26 16:07:22 -04:00
parent 446fdf9544
commit 253ef4de89
No known key found for this signature in database
GPG Key ID: EE7CF89146BB28E9
3 changed files with 22 additions and 17 deletions

View File

@ -77,7 +77,7 @@
"prepublishOnly": "npm run build",
"storybook": "start-storybook -p 6006",
"build-storybook": "build-storybook",
"prettier": "prettier --write \"{src,spec}/**/*.js\""
"prettier": "prettier --write \"{src,scripts,spec}/**/*.js\""
},
"size-limit": [
{

View File

@ -1,11 +1,11 @@
var fs = require('fs'),
emojiData = require('emoji-datasource'),
emojiLib = require('emojilib'),
inflection = require('inflection'),
mkdirp = require('mkdirp')
emojiData = require('emoji-datasource'),
emojiLib = require('emojilib'),
inflection = require('inflection'),
mkdirp = require('mkdirp')
var data = { categories: [], emojis: {}, skins: {}, short_names: {} },
categoriesIndex = {}
categoriesIndex = {}
var categories = [
['Smileys & People', 'people'],
@ -26,15 +26,15 @@ categories.forEach((category, i) => {
emojiData.sort((a, b) => {
var aTest = a.sort_order || a.short_name,
bTest = b.sort_order || b.short_name
bTest = b.sort_order || b.short_name
return aTest - bTest
})
emojiData.forEach((datum) => {
var category = datum.category,
keywords = [],
categoryIndex
keywords = [],
categoryIndex
if (!datum.category) {
throw new Error('“' + datum.short_name + '” doesnt have a category')
@ -64,11 +64,14 @@ emojiData.forEach((datum) => {
}
datum.short_names.forEach((short_name, i) => {
if (i == 0) { return }
if (i == 0) {
return
}
data.short_names[short_name] = datum.short_name
})
datum.short_names = datum.short_names.filter(i => i !== datum.short_name)
datum.short_names = datum.short_names.filter((i) => i !== datum.short_name)
datum.sheet = [datum.sheet_x, datum.sheet_y]
if (datum.text === '') delete datum.text
@ -95,11 +98,13 @@ emojiData.forEach((datum) => {
})
var flags = data.categories[categoriesIndex['Flags']]
flags.emojis = flags.emojis.filter((flag) => {
// Until browsers support Flag UN
if (flag == 'flag-un') return
return true
}).sort()
flags.emojis = flags.emojis
.filter((flag) => {
// Until browsers support Flag UN
if (flag == 'flag-un') return
return true
})
.sort()
const stringified = JSON.stringify(data).replace(/\"([A-Za-z_]+)\":/g, '$1:')
fs.writeFile('src/data/data.js', `export default ${stringified}`, (err) => {

View File

@ -2,5 +2,5 @@ var pack = require('../package.json')
module.exports = {
'process.env.NODE_ENV': 'production',
EMOJI_DATASOURCE_VERSION: pack.devDependencies['emoji-datasource']
EMOJI_DATASOURCE_VERSION: pack.devDependencies['emoji-datasource'],
}