-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
58 lines (50 loc) · 1.68 KB
/
gulpfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
"use strict";
var gulp = require('gulp');
var eslint = require('gulp-eslint');
var replace = require('gulp-replace');
var fs = require('fs');
var _ = require('underscore');
var emojiData = function(){
var data = JSON.parse(fs.readFileSync('./bower_components/emoji-data-minimal/emoji.json'));
// strip out the data which isn't needed:
var fields = ['name', 'unified', 'short_name', 'short_names', 'category',
'sort_order', 'skin_variations', 'text', 'texts'];
data = _.map(data, function(d){
d = _.pick(d, fields);
// skin variations work in a standardised way, we don't need the
// detailed data from upstream on which variations are included in
// which emoji sets:
if(d.hasOwnProperty('skin_variations')){
d.skin_variations = true;
}
return d;
});
// encode the data as an array of fields, without names:
data = _.map(data, function(d){
var r = [];
for(var i = 0; i < fields.length; i++){
r.push(d[fields[i]]);
}
return r;
});
return JSON.stringify(data);
};
gulp.task('build-js', function(){
return gulp.src([
'./lib/**/*.js'
]).pipe(replace(
'EMOJI_DATA_JSON', emojiData
)).pipe(gulp.dest('./dist'));
});
gulp.task('lint', function(){
return gulp.src([
'./lib/**/*.js',
'./*.js'
]).pipe(eslint('eslint.json')).pipe(eslint.format()).on('error', function(error){
console.error(error);
});
});
gulp.task('default', ['lint', 'build-js'], function () {
gulp.watch(["lib/**/*.js", 'emoji-data/'], ['build-js']);
gulp.watch(["lib/**/*.js"], ['lint']);
});