Description: Use optimist instead of optparse-js
 Most JavaScript projects use optimist to parse arguments. Using optparse-js
 for the build scripts here adds an unnecessary dependency on a package
 most people don't use anyway, so we patch it out.
 .
 Also, update the uglify code to work with the UglifyJS2 API.
Author: Tonnerre LOMBARD <tonnerre@ancient-solutions.com>
Forwarded: https://github.com/sockjs/sockjs-client/pull/148
Last-Update: 2014-01-08

Index: sockjs/bin/render.coffee
===================================================================
--- sockjs.orig/bin/render.coffee	2014-01-08 01:19:14.872211594 +0100
+++ sockjs/bin/render.coffee	2014-01-08 01:41:23.549438721 +0100
@@ -9,7 +9,7 @@
 
 fs = require('fs')
 uglify = require('uglify-js')
-optparse = require('optparse')
+optimist = require('optimist')
 
 array_flatten = (arr, acc) ->
     if typeof acc is 'undefined'
@@ -39,10 +39,13 @@ stringify_unicode = (str) ->
 
 
 minify = (data, minify_options)->
-    ast = uglify.parser.parse(data)
-    ast = uglify.uglify.ast_mangle(ast, minify_options)
-    ast = uglify.uglify.ast_squeeze(ast)
-    uglify.uglify.gen_code(ast, minify_options)
+    ast = uglify.parse(data)
+    compressor = uglify.Compressor()
+    ast.figure_out_scope()
+    ast = ast.transform(compressor)
+    ast.compute_char_frequency()
+    ast.mangle_names()
+    ast.print_to_string()
 
 render = (filename, depth, options) ->
     tags =
@@ -86,20 +89,34 @@
 
 
 main = ->
-    switches = [
-        ['-p', '--pretty', 'Prettify javascript']
-        ['-m', '--minify', 'Minify javascript']
-        ['-s', '--set-version [VERSION]', 'Set the value of version tag']
-    ]
-    options = {minify: false, toplevel: true, version: 'unknown'}
-    parser = new optparse.OptionParser(switches)
-    parser.on 'pretty', ->
-                   options.beautify = true
-    parser.on 'minify', ->
-                   options.minify = true
-    parser.on 'set-version', (_, version) ->
-                   options.version = version
-    filenames = parser.parse((process.ARGV || process.argv).slice(2))
+    argv = optimist.options({
+        'c': {
+            alias: 'comment',
+            default: false,
+            describe: 'Add comments',
+        },
+        'm': {
+            alias: 'minify',
+            default: true,
+            describe: 'Minify javascript',
+        },
+        'p': {
+            alias: 'pretty',
+            default: true,
+            describe: 'Prettify javascript',
+        },
+        's': {
+            alias: 'set-version',
+            default: 'unknown',
+            describe: 'Set the value of version tag',
+        }})
+        .boolean('c')
+        .boolean('m')
+        .boolean('p')
+        .string('s')
+        .argv
+    options = {comment: argv.comment, minify: argv.minify, pretty: argv.pretty, toplevel: true, version: (argv.s || "unknown")}
+    filenames = argv._
 
     content = for filename in filenames
         render(filename, '', options)
