diff --git a/lib/yargs-parser.ts b/lib/yargs-parser.ts index 47ad99dd..90078178 100644 --- a/lib/yargs-parser.ts +++ b/lib/yargs-parser.ts @@ -325,7 +325,8 @@ export class YargsParser { // current letter is an alphabetic character and next value is a number if (/[A-Za-z]/.test(letters[j]) && - /^-?\d+(\.\d*)?(e-?\d+)?$/.test(next)) { + /^-?\d+(\.\d*)?(e-?\d+)?$/.test(next) && + checkAllAliases(next, flags.bools) === false) { setArg(letters[j], next) broken = true break diff --git a/test/yargs-parser.cjs b/test/yargs-parser.cjs index 24935a26..159e1dc7 100644 --- a/test/yargs-parser.cjs +++ b/test/yargs-parser.cjs @@ -1128,6 +1128,26 @@ describe('yargs-parser', function () { result.should.have.property('b').that.is.a('boolean').and.is.true // eslint-disable-line result.should.have.property('_').and.deep.equal([123]) }) + + // Fixes: https://github.com/yargs/yargs-parser/issues/283 + it('should set boolean numeric option, with numeric option at the end of a group', function () { + const result = parser(['-x1'], { boolean: ['x', '1'] }) + expect(result).to.have.property('x', true) + expect(result).to.have.property('1', true) + }) + + it('should set boolean numeric option, with numeric option at the start of a group', function () { + const result = parser(['-1x'], { boolean: ['x', '1'] }) + expect(result).to.have.property('x', true) + expect(result).to.have.property('1', true) + }) + + it('should set boolean numeric option, with numeric option as part of a group', function () { + const result = parser(['-x1b'], { boolean: ['x', '1', 'b'] }) + expect(result).to.have.property('x', true) + expect(result).to.have.property('1', true) + expect(result).to.have.property('b', true) + }) }) describe('defaults', function () {