forked from twitter/twemoji
-
Notifications
You must be signed in to change notification settings - Fork 0
/
twemoji-dist.js
executable file
·47 lines (42 loc) · 1.05 KB
/
twemoji-dist.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
#!/usr/bin/env node
/*! Copyright Twitter Inc. and other contributors. Licensed under MIT *//*
https://github.com/twitter/twemoji/blob/gh-pages/LICENSE
*/
var fs = require('fs');
fs.writeFileSync(
'twemoji.npm.js',
[
'var location = global.location || {};',
fs.readFileSync('twemoji.js'),
'if (!location.protocol) {',
' twemoji.base = twemoji.base.replace(/^http:/, "");',
'}',
'module.exports = twemoji;'
].join('\n')
);
fs.writeFileSync(
'twemoji.amd.js',
'define(function () {\n' +
fs.readFileSync('twemoji.js').toString().replace(
/^(.)/gm, ' $1'
) +
'\n return twemoji;\n});'
);
require('child_process').spawn(
'node',
[
'node_modules/uglify-js/bin/uglifyjs',
'--verbose',
'twemoji.js',
'-o',
'twemoji.tmp.js'
]
).on('close', function () {
fs.writeFileSync(
'twemoji.min.js',
'/*! Copyright Twitter Inc. and other contributors. Licensed under MIT */\n' +
fs.readFileSync('twemoji.tmp.js')
);
fs.unlink('twemoji.tmp.js');
// gzip -c twemoji.min.js | wc -c
});