/js/lib/Socket.IO-node/support/socket.io-client/bin/build
#! | 59 lines | 50 code | 9 blank | 0 comment | 0 complexity | 8904d36269c5221cbae1e7fbb9669f55 MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1, MPL-2.0-no-copyleft-exception, BSD-3-Clause
- #!/usr/bin/env node
- /**
- * Socket.IO client
- *
- * @author Guillermo Rauch <guillermo@learnboost.com>
- * @license The MIT license.
- * @copyright Copyright (c) 2010 LearnBoost <dev@learnboost.com>
- */
- /*
- * This file will help you take all the Socket.IO client files and build socket.io.js.
- * You can later use Google Closure Compiler on it.
- */
- var fs = require('fs'),
- socket = require('../lib/io'),
- jsp = require('../lib/vendor/uglifyjs/lib/parse-js'),
- pro = require("../lib/vendor/uglifyjs/lib/process"),
- ast,
- files = [
- 'io.js',
- 'util.js',
- 'transport.js',
- 'transports/xhr.js',
- 'transports/websocket.js',
- 'transports/flashsocket.js',
- 'transports/htmlfile.js',
- 'transports/xhr-multipart.js',
- 'transports/xhr-polling.js',
- 'transports/jsonp-polling.js',
- 'socket.js',
- 'vendor/web-socket-js/swfobject.js',
- 'vendor/web-socket-js/web_socket.js'
- ],
- content = "/** Socket.IO "+ socket.io.version +" - Built with build.js */\n",
- license = "/* Socket.IO.min "+ socket.io.version +" @author Guillermo Rauch <guillermo@learnboost.com>, @license The MIT license., @copyright Copyright (c) 2010 LearnBoost <dev@learnboost.com> */\n";
- console.log('Reading files
');
- files.forEach(function(file){
- var path = __dirname + '/../lib/' + file;
- console.log(' + ' + path);
- content += fs.readFileSync(path) + "\n";
- });
- console.log('Generating
');
- fs.write(fs.openSync(__dirname + '/../socket.io.js', 'w'), content, 0, 'utf8');
- console.log(' + ' + __dirname + '/../socket.io.js');
- console.log('Uglyfying
');
- ast = jsp.parse(content);
- ast = pro.ast_mangle(ast); // get a new AST with mangled names
- ast = pro.ast_squeeze(ast);
- fs.write(fs.openSync(__dirname + '/../socket.io.min.js', 'w'), license + pro.gen_code(ast), 0, 'utf8');
- console.log(' + ' + __dirname + '/../socket.io.min.js');
- console.log('All done!');