[Pkg-javascript-commits] [node-argparse] 02/05: Imported Upstream version 1.0.3

Jonathan Horn jonathanh-guest at moszumanska.debian.org
Fri Jan 8 15:42:52 UTC 2016


This is an automated email from the git hooks/post-receive script.

jonathanh-guest pushed a commit to branch master
in repository node-argparse.

commit a8e8b3e743808155db84beda6e91798c7c09bbc5
Author: Jonathan Ulrich Horn <debian at autoit4you.de>
Date:   Fri Jan 8 16:16:08 2016 +0100

    Imported Upstream version 1.0.3
---
 .travis.yml            |  4 +++-
 CHANGELOG.md           | 12 ++++++++++++
 lib/argument_parser.js |  8 +++++---
 package.json           | 13 +++----------
 test/base.js           | 18 ++++++++++++++++++
 test/fromfile.js       |  6 +++---
 6 files changed, 44 insertions(+), 17 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index 9c44c4e..b0d8340 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,5 +1,7 @@
 language: node_js
 node_js:
  - "0.10"
+ - "0.12"
+ - stable
 before_script: "make dev-deps"
-script: "make test"
+sudo: false
diff --git a/CHANGELOG.md b/CHANGELOG.md
index fd9d2c2..f0e950a 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,15 @@
+1.0.3 / 2015-10-27
+------------------
+
+* Fix parse `=` in args: `--examplepath="C:\myfolder\env=x64"`. #84, @CatWithApple.
+
+
+1.0.2 / 2015-03-22
+------------------
+
+* Relaxed lodash version dependency.
+
+
 1.0.1 / 2015-02-20
 ------------------
 
diff --git a/lib/argument_parser.js b/lib/argument_parser.js
index 2b4cee3..c429ca9 100644
--- a/lib/argument_parser.js
+++ b/lib/argument_parser.js
@@ -53,6 +53,9 @@ var Namespace = require('./namespace');
  * [1]:http://docs.python.org/dev/library/argparse.html#argumentparser-objects
  **/
 var ArgumentParser = module.exports = function ArgumentParser(options) {
+  if (!(this instanceof ArgumentParser)) {
+    return new ArgumentParser(options);
+  }
   var self = this;
   options = options || {};
 
@@ -738,9 +741,8 @@ ArgumentParser.prototype._parseOptional = function (argString) {
 
   // if the option string before the "=" is present, return the action
   if (argString.indexOf('=') >= 0) {
-    var argStringSplit = argString.split('=');
-    optionString = argStringSplit[0];
-    argExplicit = argStringSplit[1];
+    optionString = argString.split('=', 1)[0];
+    argExplicit = argString.slice(optionString.length + 1);
 
     if (!!this._optionStringActions[optionString]) {
       action = this._optionStringActions[optionString];
diff --git a/package.json b/package.json
index 2d76fd1..76298e1 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,7 @@
 {
   "name": "argparse",
   "description": "Very powerful CLI arguments parser. Native port of argparse - python's options parsing library",
-  "version": "1.0.1",
+  "version": "1.0.3",
   "keywords": [
     "cli",
     "parser",
@@ -14,20 +14,13 @@
     "Eugene Shkuropat",
     "Paul Jacobson"
   ],
-  "bugs": {
-    "url": "https://github.com/nodeca/argparse/issues"
-  },
   "license": "MIT",
-  "repository": {
-    "type": "git",
-    "url": "git://github.com/nodeca/argparse.git"
-  },
-  "main": "./index.js",
+  "repository": "nodeca/argparse",
   "scripts": {
     "test": "make test"
   },
   "dependencies": {
-    "lodash": "~3.2",
+    "lodash": ">= 3.2.0 < 4.0.0",
     "sprintf-js": "~1.0.2"
   },
   "devDependencies": {
diff --git a/test/base.js b/test/base.js
index 4493c0c..03185db 100644
--- a/test/base.js
+++ b/test/base.js
@@ -123,6 +123,16 @@ describe('base', function () {
     args = parser.parseArgs(['-1']);
     assert.equal(args.bar, -1);
   });
+  
+  it("should parse arguments with '='", function () {
+    parser = new ArgumentParser({debug: true});
+    parser.addArgument(['-f', '--foo']);
+    parser.addArgument([ 'bar' ]);
+
+    args = parser.parseArgs('-f="foo=nice=path" "bar=nice=path"'.split(' '));
+    assert.equal(args.foo, '"foo=nice=path"');
+    assert.equal(args.bar, '"bar=nice=path"');
+  });
 
   it("No negative number options; neg number is positional argument", function () {
     parser = new ArgumentParser({debug: true});
@@ -244,4 +254,12 @@ describe('base', function () {
       args = parser.parseArgs([ '-y' ]);
     });
   });
+
+  it('should support instantiation without new', function () {
+    assert.doesNotThrow(function () {
+      /* jshint -W064 */
+      parser = ArgumentParser({debug: true});
+      /* jshint +W064 */
+    });
+  });
 });
diff --git a/test/fromfile.js b/test/fromfile.js
index f7d39a7..27bfb8f 100644
--- a/test/fromfile.js
+++ b/test/fromfile.js
@@ -44,12 +44,12 @@ describe('from file', function () {
     args = parser.parseArgs(['X', '@recursive', 'Z', '-a', 'B']);
     assert.deepEqual(args, {a: 'B', x: 'X', y: ['hello world!', 'Z']});
   });
-  it('fest reading arguments from an invalid file', function () {
+  it('test reading arguments from an invalid file', function () {
     assert.throws(
       function () {
         args = parser.parseArgs(['@invalid']);
       },
-      /ENOENT, no such file or directory/
+      /ENOENT[:,] no such file or directory/
     );
   });
   it('test reading arguments from an missing file', function () {
@@ -57,7 +57,7 @@ describe('from file', function () {
       function () {
         args = parser.parseArgs(['@missing']);
       },
-      /ENOENT, no such file or directory/
+      /ENOENT[:,] no such file or directory/
     );
   });
   it('test custom convertArgLineToArgs function', function () {

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-argparse.git



More information about the Pkg-javascript-commits mailing list