1
0
mirror of https://github.com/twitter/twemoji.git synced 2024-06-15 03:35:16 +00:00
twemoji/2/scripts/create-dist

50 lines
1.2 KiB
Plaintext
Raw Normal View History

#!/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);
}
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.min.js')
]
).on('close', function () {
fs.writeFileSync(
file('twemoji.min.js'),
'/*! Copyright Twitter Inc. and other contributors. Licensed under MIT */\n' +
fs.readFileSync(file('twemoji.min.js')) + '\n'
);
});