[Pkg-javascript-commits] [node-yargs-parser] 01/03: New upstream version 4.1.0
Praveen Arimbrathodiyil
praveen at moszumanska.debian.org
Sat Nov 26 11:23:36 UTC 2016
This is an automated email from the git hooks/post-receive script.
praveen pushed a commit to branch master
in repository node-yargs-parser.
commit d75a192873ca6f38489c2e0c532c7869f34eb371
Author: Praveen Arimbrathodiyil <praveen at debian.org>
Date: Sat Nov 26 16:35:34 2016 +0530
New upstream version 4.1.0
---
CHANGELOG.md | 11 +++++++++++
index.js | 4 ++--
package.json | 4 ++--
test/yargs-parser.js | 24 ++++++++++++++++++++++++
4 files changed, 39 insertions(+), 4 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 547591d..3d6d504 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,17 @@
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
+<a name="4.1.0"></a>
+# [4.1.0](https://github.com/yargs/yargs-parser/compare/v4.0.2...v4.1.0) (2016-11-07)
+
+
+### Features
+
+* apply coercions to default options ([#65](https://github.com/yargs/yargs-parser/issues/65)) ([c79052b](https://github.com/yargs/yargs-parser/commit/c79052b))
+* handle dot notation boolean options ([#63](https://github.com/yargs/yargs-parser/issues/63)) ([02c3545](https://github.com/yargs/yargs-parser/commit/02c3545))
+
+
+
<a name="4.0.2"></a>
## [4.0.2](https://github.com/yargs/yargs-parser/compare/v4.0.1...v4.0.2) (2016-09-30)
diff --git a/index.js b/index.js
index 564cb2e..0d3ed26 100644
--- a/index.js
+++ b/index.js
@@ -279,8 +279,8 @@ function parse (args, opts) {
setConfig(argv)
setConfigObjects()
applyEnvVars(argv, false)
- applyCoercions(argv)
applyDefaultsAndAliases(argv, flags.aliases, defaults)
+ applyCoercions(argv)
// for any counts either not in args or without an explicit default, set to 0
Object.keys(flags.counts).forEach(function (key) {
@@ -540,7 +540,7 @@ function parse (args, opts) {
o[key] = increment(o[key])
} else if (o[key] === undefined && checkAllAliases(key, flags.arrays)) {
o[key] = Array.isArray(value) ? value : [value]
- } else if (o[key] === undefined || checkAllAliases(key, flags.bools) || checkAllAliases(key, flags.counts)) {
+ } else if (o[key] === undefined || checkAllAliases(key, flags.bools) || checkAllAliases(keys.join('.'), flags.bools) || checkAllAliases(key, flags.counts)) {
o[key] = value
} else if (Array.isArray(o[key])) {
o[key].push(value)
diff --git a/package.json b/package.json
index 81c511e..a2f4baa 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "yargs-parser",
- "version": "4.0.2",
+ "version": "4.1.0",
"description": "the mighty option parser used by yargs",
"main": "index.js",
"scripts": {
@@ -31,7 +31,7 @@
"mocha": "^3.0.1",
"nyc": "^8.1.0",
"standard": "^8.0.0",
- "standard-version": "^2.1.2"
+ "standard-version": "^3.0.0"
},
"dependencies": {
"camelcase": "^3.0.0"
diff --git a/test/yargs-parser.js b/test/yargs-parser.js
index dac993c..8529d85 100644
--- a/test/yargs-parser.js
+++ b/test/yargs-parser.js
@@ -198,6 +198,18 @@ describe('yargs-parser', function () {
parse.should.have.property('_').and.deep.equal(['one', 'two', 'three'])
})
+ it('should correctly parse dot-notation boolean flags', function () {
+ var parse = parser(['--nested', '--n.v', '--n.y', 'foo'], {
+ boolean: ['nested', 'n.v']
+ })
+
+ parse.should.have.property('nested', true).and.be.a('boolean')
+ parse.should.have.property('n').and.deep.equal({
+ v: true,
+ y: 'foo'
+ })
+ })
+
it('should preserve newlines in option values', function () {
var args = parser(['-s', 'X\nX'])
args.should.have.property('_').with.length(0)
@@ -1992,6 +2004,18 @@ describe('yargs-parser', function () {
parsed.foo.bar.should.equal('nananana, batman!')
})
+ it('applies coercion to defaults', function () {
+ var parsed = parser([], {
+ default: { foo: 'bar' },
+ coerce: {
+ foo: function (val) {
+ return val.toUpperCase()
+ }
+ }
+ })
+ parsed.foo.should.equal('BAR')
+ })
+
it('applies coercion function to an implicit array', function () {
var parsed = parser(['--foo', '99', '-f', '33'], {
coerce: {
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-yargs-parser.git
More information about the Pkg-javascript-commits
mailing list