yargs / yargs/yargs-parser

Empty array values being ignored

Open
#193 9 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug needs investigation p1
Dominant language
JavaScript
Stars
519
Forks
129
Avg merge
1h 34m
Merged PRs (30d)
1

Description

Hi!

I have a program that passes positional arguments to another program, and discovered that empty strings are removed from the final array.

The folowing code:

var yargs = require('yargs');

var argv = yargs
    .options('A', {
        type: 'array'
    }).argv;

console.log(argv.A);
node .\index.js -A=test1 -A= -A=test3 -A= 

Outputs:

[ 'test1', 'test3' ]

Expected:

[ 'test1', '', 'test3', '' ]

Versions:
yargs: 13.3.0
yargs-parser: 13.1.1

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the reported Node.js command with yargs 13.3.0 and yargs-parser 13.1.1, focusing on repeated -A array arguments with empty values. Done means the resulting argv.A preserves each empty string in its original position, matching the expected array.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.