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