Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: create result.values with null prototype #111

Merged
merged 9 commits into from
Apr 17, 2022
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ const parseArgs = ({
);

const result = {
values: {},
values: { __proto__: null },
positionals: []
};

Expand Down
14 changes: 14 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -378,3 +378,17 @@ test('invalid short option length', () => {
code: 'ERR_INVALID_ARG_VALUE'
});
});

test('null prototype: when no options then values.toString is undefined', () => {
const result = parseArgs({ args: [] });
assert.strictEqual(result.values.toString, undefined);
});

test('null prototype: when --toString then values.toString is true', () => {
const args = ['--toString'];
const options = { toString: { type: 'boolean' } };
const expectedResult = { values: { __proto__: null, toString: true }, positionals: [] };

const result = parseArgs({ args, options });
assert.deepStrictEqual(result, expectedResult);
});