xmpp.chapril.org-conversejs/store.js/build.js
2012-07-01 12:05:37 +02:00

23 lines
673 B
JavaScript
Executable File

#!/usr/local/bin/node
var fs = require('fs'),
uglify = require('uglify-js')
var storeJS = fs.readFileSync(__dirname + '/store.js').toString(),
jsonJS = fs.readFileSync(__dirname + '/json.js').toString(),
copy = '/* Copyright (c) 2010-2012 Marcus Westin */'
console.log('building and minifying...')
buildFile(storeJS, 'store.min.js')
buildFile(jsonJS + '\n\n' + storeJS, 'store+json2.min.js')
console.log('done')
function buildFile(js, name) {
var ast = uglify.parser.parse(js)
ast = uglify.uglify.ast_mangle(ast)
ast = uglify.uglify.ast_squeeze(ast)
var minifiedJS = uglify.uglify.gen_code(ast)
fs.writeFile(__dirname + '/' + name, copy + '\n' + minifiedJS)
}