Comparing version 5.0.1 to 5.1.0
@@ -14,3 +14,3 @@ 'use strict'; | ||
const makeArg = (key, val) => { | ||
key = '--' + key.replace(/[A-Z]/g, '-$&').toLowerCase(); // eslint-disable-line prefer-template | ||
key = '--' + (opts.allowCamelCase ? key : key.replace(/[A-Z]/g, '-$&').toLowerCase()); | ||
@@ -36,2 +36,3 @@ if (opts.useEquals) { | ||
// TODO: use for-of loop and Object.entries when targeting Node.js 6 | ||
Object.keys(input).forEach(key => { | ||
@@ -86,7 +87,7 @@ const val = input[key]; | ||
extraArgs.forEach(extraArgVal => { | ||
args.push(String(extraArgVal)); | ||
}); | ||
for (const x of extraArgs) { | ||
args.push(String(x)); | ||
} | ||
return args; | ||
}; |
{ | ||
"name": "dargs", | ||
"version": "5.0.1", | ||
"version": "5.1.0", | ||
"description": "Reverse minimist. Convert an object of options into an array of command-line arguments.", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -123,4 +123,6 @@ # dargs [![Build Status](https://travis-ci.org/sindresorhus/dargs.svg?branch=master)](https://travis-ci.org/sindresorhus/dargs) | ||
Setting this to `false` makes it return the key and value as separate array items instead of using a `=` separator in one item. This can be useful for tools that doesn't support `--foo=bar` style flags. For example: | ||
Setting this to `false` makes it return the key and value as separate array items instead of using a `=` separator in one item. This can be useful for tools that doesn't support `--foo=bar` style flags. | ||
###### Example | ||
```js | ||
@@ -142,5 +144,22 @@ console.log(dargs({foo: 'bar'}, {useEquals: false})); | ||
##### allowCamelCase | ||
Type: `boolean`<br> | ||
Default: `false` | ||
By default, camelCased keys will be hyphenated. Enabling this will bypass the conversion process. | ||
###### Example | ||
```js | ||
console.log(dargs({fooBar: 'baz'})); | ||
//=> ['--foo-bar', 'baz'] | ||
console.log(dargs({fooBar: 'baz'}, {allowCamelCase: true})); | ||
//=> ['--fooBar', 'baz'] | ||
``` | ||
## License | ||
MIT © [Sindre Sorhus](https://sindresorhus.com) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6766
69
164