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

Fix isMultiple not handling multi-word flags #150

Merged
merged 1 commit into from May 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion index.js
Expand Up @@ -2,6 +2,7 @@
const path = require('path');
const buildParserOptions = require('minimist-options');
const yargs = require('yargs-parser');
const camelCase = require('camelcase');
const camelcaseKeys = require('camelcase-keys');
const decamelizeKeys = require('decamelize-keys');
const trimNewlines = require('trim-newlines');
Expand Down Expand Up @@ -83,7 +84,7 @@ Convert to alternative syntax for coercing values to expected type, according to
const convertToTypedArrayOption = (arrayOption, flags) =>
arrify(arrayOption).map(flagKey => ({
key: flagKey,
[flags[flagKey].type || 'string']: true
[flags[camelCase(flagKey, '-')].type || 'string']: true
}));

const validateFlags = (flags, options) => {
Expand Down
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -42,6 +42,7 @@
"dependencies": {
"@types/minimist": "^1.2.0",
"arrify": "^2.0.1",
"camelcase": "^6.0.0",
"camelcase-keys": "^6.2.2",
"decamelize-keys": "^1.1.0",
"hard-rejection": "^2.1.0",
Expand Down
15 changes: 15 additions & 0 deletions test/test.js
Expand Up @@ -482,6 +482,21 @@ test('isMultiple - multiple flag default values', t => {
});
});

// Happened in production 2020-05-10: https://github.com/sindresorhus/meow/pull/143#issuecomment-626287226
test('isMultiple - handles multi-word flag name', t => {
t.deepEqual(meow({
argv: ['--foo-bar=baz'],
flags: {
fooBar: {
type: 'string',
isMultiple: true
}
}
}).flags, {
fooBar: ['baz']
});
});

if (NODE_MAJOR_VERSION >= 14) {
test('supports es modules', async t => {
try {
Expand Down