Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

yargs-parser

Package Overview
Dependencies
Maintainers
2
Versions
83
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

yargs-parser - npm Package Compare versions

Comparing version 14.0.0 to 15.0.0

14

CHANGELOG.md

@@ -5,2 +5,16 @@ # Changelog

## [15.0.0](https://github.com/yargs/yargs-parser/compare/v14.0.0...v15.0.0) (2019-10-07)
### Features
* rework `collect-unknown-options` into `unknown-options-as-args`, providing more comprehensive functionality ([ef771ca](https://github.com/yargs/yargs-parser/commit/ef771ca))
### BREAKING CHANGES
* rework `collect-unknown-options` into `unknown-options-as-args`, providing more comprehensive functionality
## [14.0.0](https://github.com/yargs/yargs-parser/compare/v13.1.1...v14.0.0) (2019-09-06)

@@ -7,0 +21,0 @@

29

index.js

@@ -30,3 +30,3 @@ var camelCase = require('camelcase')

'strip-dashed': false,
'collect-unknown-options': false
'unknown-options-as-args': false
}, opts.configuration)

@@ -147,3 +147,3 @@ var defaults = opts.default || {}

if (configuration['collect-unknown-options'] && isUnknownOption(arg)) {
if (isUnknownOptionAsArg(arg)) {
argv._.push(arg)

@@ -366,3 +366,3 @@ // -- separated by =

for (ii = i + 1; ii < args.length; ii++) {
if (!args[ii].match(/^-[^0-9]/)) available++
if (!args[ii].match(/^-[^0-9]/) || isUnknownOptionAsArg(args[ii])) available++
else break

@@ -390,3 +390,3 @@ }

argsToSet.push(true)
} else if (isUndefined(next) || (/^-/.test(next) && !negative.test(next))) {
} else if (isUndefined(next) || (/^-/.test(next) && !negative.test(next) && !isUnknownOptionAsArg(next))) {
// for keys without value ==> argsToSet remains an empty []

@@ -400,3 +400,3 @@ // set user default value, if available

next = args[ii]
if (/^-/.test(next) && !negative.test(next)) break
if (/^-/.test(next) && !negative.test(next) && !isUnknownOptionAsArg(next)) break
i = ii

@@ -769,23 +769,16 @@ argsToSet.push(processValue(key, next))

function hasAnyFlag (key) {
var isSet = false
// XXX Switch to [].concat(...Object.values(flags)) once node.js 6 is dropped
var toCheck = [].concat(...Object.keys(flags).map(k => flags[k]))
toCheck.forEach(function (flag) {
if (flag[key]) isSet = flag[key]
return toCheck.some(function (flag) {
return flag[key]
})
return isSet
}
function hasFlagsMatching (arg, ...patterns) {
var hasFlag = false
var toCheck = [].concat(...patterns)
toCheck.forEach(function (pattern) {
return toCheck.some(function (pattern) {
var match = arg.match(pattern)
if (match && hasAnyFlag(match[1])) {
hasFlag = true
}
return match && hasAnyFlag(match[1])
})
return hasFlag
}

@@ -818,2 +811,6 @@

function isUnknownOptionAsArg (arg) {
return configuration['unknown-options-as-args'] && isUnknownOption(arg)
}
function isUnknownOption (arg) {

@@ -820,0 +817,0 @@ // ignore negative numbers

{
"name": "yargs-parser",
"version": "14.0.0",
"version": "15.0.0",
"description": "the mighty option parser used by yargs",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -389,8 +389,8 @@ # yargs-parser

### collect unknown options
### unknown options as args
* default: `false`
* key: `collect-unknown-options`
* key: `unknown-options-as-args`
Should unknown options be collected into `_`? An unknown option is one that is not
Should unknown options be treated like regular arguments? An unknown option is one that is not
configured in `opts`.

@@ -401,4 +401,4 @@

```sh
node example.js --unknown-option --known-option 2
{ _: [], unknownOption: true, knownOption: 2 }
node example.js --unknown-option --known-option 2 --string-option --unknown-option2
{ _: [], unknownOption: true, knownOption: 2, stringOption: '', unknownOption2: true }
```

@@ -409,4 +409,4 @@

```sh
node example.js --unknown-option --known-option 2
{ _: ['--unknown-option'], knownOption: 2 }
node example.js --unknown-option --known-option 2 --string-option --unknown-option2
{ _: ['--unknown-option'], knownOption: 2, stringOption: '--unknown-option2' }
```

@@ -413,0 +413,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc