Skip to content

Commit

Permalink
💄 Prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
EtienneLem committed Apr 26, 2018
1 parent 446fdf9 commit 253ef4d
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 17 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
{
Expand Down
35 changes: 20 additions & 15 deletions scripts/build-data.js
Original file line number Diff line number Diff line change
@@ -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'],
Expand All @@ -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 + '” doesn’t have a category')
Expand Down Expand Up @@ -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
Expand All @@ -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) => {
Expand Down
2 changes: 1 addition & 1 deletion scripts/define.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
}

0 comments on commit 253ef4d

Please sign in to comment.