PageRenderTime 171ms CodeModel.GetById 91ms app.highlight 0ms RepoModel.GetById 60ms app.codeStats 0ms

/js/lib/Socket.IO-node/support/socket.io-client/bin/build

http://github.com/onedayitwillmake/RealtimeMultiplayerNodeJs
#! | 59 lines | 50 code | 9 blank | 0 comment | 0 complexity | 8904d36269c5221cbae1e7fbb9669f55 MD5 | raw file
 1#!/usr/bin/env node
 2
 3/**
 4 * Socket.IO client
 5 * 
 6 * @author Guillermo Rauch <guillermo@learnboost.com>
 7 * @license The MIT license.
 8 * @copyright Copyright (c) 2010 LearnBoost <dev@learnboost.com>
 9 */
10
11/*
12 * This file will help you take all the Socket.IO client files and build socket.io.js.
13 * You can later use Google Closure Compiler on it.
14 */
15
16var fs = require('fs'),
17	socket = require('../lib/io'),
18	jsp = require('../lib/vendor/uglifyjs/lib/parse-js'),
19	pro = require("../lib/vendor/uglifyjs/lib/process"),
20	ast,
21	files = [
22		'io.js',
23		'util.js',
24		'transport.js',
25		'transports/xhr.js',
26		'transports/websocket.js',
27		'transports/flashsocket.js',
28		'transports/htmlfile.js',
29		'transports/xhr-multipart.js',
30		'transports/xhr-polling.js',
31		'transports/jsonp-polling.js',
32		'socket.js',
33		'vendor/web-socket-js/swfobject.js',
34		'vendor/web-socket-js/web_socket.js'
35	],
36	content = "/** Socket.IO "+ socket.io.version +" - Built with build.js */\n",
37	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";
38
39console.log('Reading files…');
40
41files.forEach(function(file){
42	var path = __dirname + '/../lib/' + file;
43	console.log(' + ' + path);
44	content += fs.readFileSync(path) + "\n"; 	
45});
46
47console.log('Generating…');
48
49fs.write(fs.openSync(__dirname + '/../socket.io.js', 'w'), content, 0, 'utf8');
50console.log(' + ' + __dirname + '/../socket.io.js');
51
52console.log('Uglyfying…');
53ast = jsp.parse(content);
54ast = pro.ast_mangle(ast); // get a new AST with mangled names
55ast = pro.ast_squeeze(ast);
56fs.write(fs.openSync(__dirname + '/../socket.io.min.js', 'w'), license + pro.gen_code(ast), 0, 'utf8');
57console.log(' + ' + __dirname + '/../socket.io.min.js');
58
59console.log('All done!');