[Pkg-javascript-commits] [node-dargs] 22/54: Add support for `--no-` arguments
Bastien Roucariès
rouca at moszumanska.debian.org
Wed Sep 6 09:41:03 UTC 2017
This is an automated email from the git hooks/post-receive script.
rouca pushed a commit to branch master
in repository node-dargs.
commit 02cb1364b05dc4c0fc183e6ecabf59321c457aa5
Author: Kevin Martensson <kevinmartensson at gmail.com>
Date: Thu Nov 6 08:27:23 2014 +0100
Add support for `--no-` arguments
---
index.js | 4 ++++
readme.md | 3 ++-
test.js | 4 ++++
3 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/index.js b/index.js
index fca680d..3a27b5d 100644
--- a/index.js
+++ b/index.js
@@ -23,6 +23,10 @@ module.exports = function (opts, excludes, includes) {
args.push(createArg(key));
}
+ if (val === false) {
+ args.push(createArg('no-' + key));
+ }
+
if (typeof val === 'string') {
args.push(createArg(key, val));
}
diff --git a/readme.md b/readme.md
index 37edd98..2666fcb 100644
--- a/readme.md
+++ b/readme.md
@@ -20,7 +20,7 @@ var dargs = require('dargs');
var options = {
foo: 'bar',
hello: true, // results in only the key being used
- cake: false, // ignored
+ cake: false, // prepends `no-` before the key
camelCase: 5, // camelCase is slugged to `camel-case`
multiple: ['value', 'value2'], // converted to multiple arguments
sad: ':('
@@ -34,6 +34,7 @@ console.log(dargs(options, excludes));
[
'--foo=bar',
'--hello',
+ '--no-cake',
'--camel-case=5',
'--multiple=value',
'--multiple=value2'
diff --git a/test.js b/test.js
index 9d91071..94c3082 100644
--- a/test.js
+++ b/test.js
@@ -20,6 +20,7 @@ it('convert options to cli flags', function () {
var expected = [
'--a=foo',
'--b',
+ '--no-c',
'--d=5',
'--e=foo',
'--e=bar',
@@ -34,6 +35,7 @@ it('exclude options', function () {
var actual = dargs(fixture, ['b', 'e', 'h', 'i']);
var expected = [
'--a=foo',
+ '--no-c',
'--d=5',
'--camel-case-camel'
];
@@ -44,6 +46,7 @@ it('includes options', function () {
var actual = dargs(fixture, [], ['a', 'c', 'd', 'e', 'camelCaseCamel']);
var expected = [
'--a=foo',
+ '--no-c',
'--d=5',
'--e=foo',
'--e=bar',
@@ -55,6 +58,7 @@ it('includes options', function () {
it('excludes and includes options', function () {
var actual = dargs(fixture, ['a', 'd'], ['a', 'c', 'd', 'e', 'camelCaseCamel']);
var expected = [
+ '--no-c',
'--e=foo',
'--e=bar',
'--camel-case-camel'
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-dargs.git
More information about the Pkg-javascript-commits
mailing list