[Pkg-javascript-commits] [sockjs-client] 08/350: Use optimist rather than optparse-js for parsing command line arguments. optimist is much more wide-spread, so this eliminates an extra dependency for most people.
tonnerre at ancient-solutions.com
tonnerre at ancient-solutions.com
Fri Aug 5 01:03:26 UTC 2016
This is an automated email from the git hooks/post-receive script.
tonnerre-guest pushed a commit to branch upstream
in repository sockjs-client.
commit 7164b1ab698f0626f8e1e23a13c6c3a17124872e
Author: Tonnerre LOMBARD <tonnerre at ancient-solutions.com>
Date: Wed Jan 8 01:56:08 2014 +0100
Use optimist rather than optparse-js for parsing command line arguments.
optimist is much more wide-spread, so this eliminates an extra
dependency for most people.
---
Makefile | 6 +++---
bin/render.coffee | 44 +++++++++++++++++++++++++++++---------------
package.json | 2 +-
3 files changed, 33 insertions(+), 19 deletions(-)
diff --git a/Makefile b/Makefile
index 2b81b00..95957f4 100644
--- a/Makefile
+++ b/Makefile
@@ -8,15 +8,15 @@ build: sockjs.js sockjs.min.js
sockjs.js: lib/*js version
@$(COFFEE) -v > /dev/null
- $(COFFEE) bin/render.coffee --set-version $(VER) lib/all.js > $@
+ $(COFFEE) bin/render.coffee --set-version "$(VER)" lib/all.js > $@
sockjs.min.js: lib/*js version
@$(COFFEE) -v > /dev/null
- $(COFFEE) bin/render.coffee --set-version $(VER) --minify lib/all.js > $@
+ $(COFFEE) bin/render.coffee --set-version "$(VER)" --minify lib/all.js > $@
sockjs.pretty.js: lib/*js version
@$(COFFEE) -v > /dev/null
- $(COFFEE) bin/render.coffee --set-version $(VER) --minify --pretty lib/all.js > $@
+ $(COFFEE) bin/render.coffee --set-version "$(VER)" --minify --pretty lib/all.js > $@
tests/html/lib/sockjs.js: sockjs.js
cp $< $@
diff --git a/bin/render.coffee b/bin/render.coffee
index b33bf39..a686493 100644
--- a/bin/render.coffee
+++ b/bin/render.coffee
@@ -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'
@@ -86,20 +86,34 @@ render = (filename, depth, options) ->
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)
diff --git a/package.json b/package.json
index b95d669..8609578 100644
--- a/package.json
+++ b/package.json
@@ -11,7 +11,7 @@
"devDependencies": {
"uglify-js" : "1.2.5",
"coffee-script" : "1.2.x",
- "optparse" : "1.0.3",
+ "optimist" : "0.3.5",
"node-static" : "0.5.9"
},
"private": true
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/sockjs-client.git
More information about the Pkg-javascript-commits
mailing list