Skip to content

Commit

Permalink
fix formatting and add a missing "let" keyword
Browse files Browse the repository at this point in the history
  • Loading branch information
henderea committed Jun 26, 2019
1 parent 72c82df commit 7a75525
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
26 changes: 13 additions & 13 deletions index.js
Expand Up @@ -218,7 +218,7 @@ function parse (args, opts) {
next = args[i + 1]
key = arg.match(/^-(.\..+)/)[1]

if(!configuration['ignore-unknown-options'] || hasAnyFlag(key)) {
if (!configuration['ignore-unknown-options'] || hasAnyFlag(key)) {
if (next !== undefined && !next.match(/^-/) &&
!checkAllAliases(key, flags.bools) &&
!checkAllAliases(key, flags.counts)) {
Expand All @@ -233,7 +233,7 @@ function parse (args, opts) {
} else if (arg.match(/^-[^-]+/) && !arg.match(negative)) {
letters = arg.slice(1, -1).split('')
broken = false
unmatched = []
let unmatched = []

for (var j = 0; j < letters.length; j++) {
next = arg.slice(j + 2)
Expand All @@ -253,9 +253,9 @@ function parse (args, opts) {
} else if (!configuration['ignore-unknown-options'] || hasAnyFlag(key)) {
setArg(key, value)
} else {
unmatched.push(key);
unmatched.push('=');
unmatched.push(value);
unmatched.push(key)
unmatched.push('=')
unmatched.push(value)
}

broken = true
Expand All @@ -266,8 +266,8 @@ function parse (args, opts) {
if (!configuration['ignore-unknown-options'] || hasAnyFlag(letters[j])) {
setArg(letters[j], next)
} else {
unmatched.push(letters[j]);
unmatched.push(next);
unmatched.push(letters[j])
unmatched.push(next)
}
continue
}
Expand All @@ -278,8 +278,8 @@ function parse (args, opts) {
if (!configuration['ignore-unknown-options'] || hasAnyFlag(letters[j])) {
setArg(letters[j], next)
} else {
unmatched.push(letters[j]);
unmatched.push(next);
unmatched.push(letters[j])
unmatched.push(next)
}
broken = true
break
Expand All @@ -289,8 +289,8 @@ function parse (args, opts) {
if (!configuration['ignore-unknown-options'] || hasAnyFlag(letters[j])) {
setArg(letters[j], next)
} else {
unmatched.push(letters[j]);
unmatched.push(next);
unmatched.push(letters[j])
unmatched.push(next)
}
broken = true
break
Expand Down Expand Up @@ -326,7 +326,7 @@ function parse (args, opts) {
setArg(key, defaultValue(key))
}
} else {
unmatched.push(key);
unmatched.push(key)
}
}
if (unmatched.length > 0) {
Expand Down Expand Up @@ -794,7 +794,7 @@ function parse (args, opts) {

return isSet
}

function hasAnyFlag (key) {
var isSet = false
var toCheck = [].concat(Object.values(flags))
Expand Down
14 changes: 7 additions & 7 deletions test/yargs-parser.js
Expand Up @@ -3092,7 +3092,7 @@ describe('yargs-parser', function () {
})
argv.should.deep.equal({
_: ['-u=2'],
'k': 1
'k': 1
})
})
it('should ignore unknown options in short format followed by hyphen', function () {
Expand All @@ -3104,7 +3104,7 @@ describe('yargs-parser', function () {
})
argv.should.deep.equal({
_: ['-u-'],
'k': '-'
'k': '-'
})
})
it('should ignore unknown options in short format separated by space', function () {
Expand All @@ -3116,7 +3116,7 @@ describe('yargs-parser', function () {
})
argv.should.deep.equal({
_: ['-u', 2],
'k': 1
'k': 1
})
})
it('should ignore unknown options in short format followed by a number', function () {
Expand All @@ -3128,7 +3128,7 @@ describe('yargs-parser', function () {
})
argv.should.deep.equal({
_: ['-u2'],
'k': 1
'k': 1
})
})
it('should ignore unknown options in short format followed by a non-word character', function () {
Expand All @@ -3140,7 +3140,7 @@ describe('yargs-parser', function () {
})
argv.should.deep.equal({
_: ['-u/2/'],
'k': '/1/'
'k': '/1/'
})
})
})
Expand All @@ -3153,7 +3153,7 @@ describe('yargs-parser', function () {
})
argv.should.deep.equal({
_: ['-u'],
'k': true,
'k': true,
'v': true
})
it('should ignore unknown options in short format with multiple flags in one argument where an unknown flag is at the end', function () {
Expand All @@ -3165,7 +3165,7 @@ describe('yargs-parser', function () {
})
argv.should.deep.equal({
_: ['-u'],
'k': true,
'k': true,
'v': true
})
})
Expand Down

0 comments on commit 7a75525

Please sign in to comment.