2016-02-28 11:37:17 +00:00
|
|
|
#!/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');
|
|
|
|
var path = require('path');
|
|
|
|
|
|
|
|
function file(which) {
|
2016-02-29 13:36:17 +00:00
|
|
|
return path.join(__dirname, '..', which);
|
2016-02-28 11:37:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fs.writeFileSync(
|
|
|
|
file('twemoji.npm.js'),
|
|
|
|
[
|
|
|
|
'var location = global.location || {};',
|
|
|
|
fs.readFileSync(file('twemoji.js')),
|
|
|
|
'if (!location.protocol) {',
|
|
|
|
' twemoji.base = twemoji.base.replace(/^http:/, "");',
|
|
|
|
'}',
|
|
|
|
'module.exports = twemoji;'
|
|
|
|
].join('\n')
|
|
|
|
);
|
|
|
|
|
|
|
|
fs.writeFileSync(
|
|
|
|
file('twemoji.amd.js'),
|
|
|
|
'define(function () {\n' +
|
|
|
|
fs.readFileSync(file('twemoji.js')).toString().replace(
|
|
|
|
/^(.)/gm, ' $1'
|
|
|
|
) +
|
|
|
|
'\n return twemoji;\n});'
|
|
|
|
);
|
|
|
|
|
|
|
|
require('child_process').spawn(
|
|
|
|
'node',
|
|
|
|
[
|
|
|
|
path.join(__dirname, '../../', 'node_modules/uglify-js/bin/uglifyjs'),
|
|
|
|
'--verbose',
|
|
|
|
file('twemoji.js'),
|
|
|
|
'-o',
|
|
|
|
file('twemoji.tmp.js')
|
|
|
|
]
|
|
|
|
).on('close', function () {
|
|
|
|
fs.writeFileSync(
|
|
|
|
file('twemoji.min.js'),
|
|
|
|
'/*! Copyright Twitter Inc. and other contributors. Licensed under MIT */\n' +
|
2016-03-02 14:34:50 +00:00
|
|
|
fs.readFileSync(file('twemoji.tmp.js'))
|
2016-02-28 11:37:17 +00:00
|
|
|
);
|
|
|
|
fs.unlink(file('twemoji.tmp.js'));
|
|
|
|
// gzip -c twemoji.min.js | wc -c
|
|
|
|
});
|