This repository has been archived by the owner on Jan 25, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Gruntfile.js
134 lines (128 loc) · 2.66 KB
/
Gruntfile.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
'use strict'
var grunt = require('grunt');
var htmlentities = require('htmlentities');
require('string.fromcodepoint');
function uStr(str) {
var ex = str.split('-');
var hex = ex.map(function(x) {
return parseInt(x, 16);
});
return String.fromCodePoint.apply(this, hex);
}
grunt.registerTask('pidgin', 'Generate Emoji One theme file', function() {
var opts = this.options({
dest: './dist/theme',
});
var version = grunt.file.readJSON('package.json').version;
var emoji = require('emojione/emoji');
var theme = {
name: 'Emoji One (' + version + ')',
desc: 'Emoji One unicode ported to Pidgin',
icon: '1F40C.png',
author: 'Niclas Hoyer',
repl: []
}
Object.keys(emoji).forEach(function(k) {
var e = emoji[k];
var alias = []
alias.push(e.unicode + '.png');
alias.push(uStr(e.unicode));
//alias = alias.concat(e.unicode_alternates.map(uStr));
alias.push(e.shortname);
alias = alias.concat(e.aliases);
alias = alias.concat(e.aliases_ascii.map(function(x) {
return htmlentities.decode(x);
}));
theme.repl.push(alias);
});
theme.repl = theme.repl.map(function(x) {
return x.join('\t');
});
var themestr = '';
themestr += 'Name=' + theme.name + '\n';
themestr += 'Description=' + theme.desc + '\n';
themestr += 'Icon=' + theme.icon + '\n';
themestr += 'Author=' + theme.author + '\n';
themestr += '\n[default]\n'
themestr += theme.repl.join('\n');
grunt.file.write(opts.dest, themestr);
});
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-compress');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-pngmin');
grunt.loadNpmTasks('grunt-multiresize');
grunt.registerTask('default', [
'clean:all',
'multiresize',
'pngmin',
'pidgin',
'copy',
'compress',
'clean:build']
);
grunt.initConfig({
clean: {
build: ['./dist/*.png', './dist/theme', './dist/*.md'],
all: ['./dist']
},
copy: {
readme: {
files: [{
src: ['./README.md'],
dest: './dist/'
}]
},
license: {
files: [{
src: ['./LICENSE.md'],
dest: './dist/'
}]
}
},
multiresize: {
options: {
destSizes: ['24x24']
},
png: {
files: [{
expand: true,
src: ['./node_modules/emojione/assets/png/*'],
dest: './dist/',
ext: '.png',
flatten: true,
destSizes: ['24x24']
}],
}
},
pngmin: {
options: {
ext: '.png',
force: true,
quality: {
min: 90,
max: 100
}
},
png: {
files: [{
expand: true,
src: ['./dist/*.png'],
}]
}
},
compress: {
options: {
mode: 'tgz',
archive: './dist/pidgin-emojione.tar.gz'
},
theme: {
files: [{
expand: true,
src: ['./dist/*'],
flatten: true,
dest: './emojione/'
}]
}
}
});