Skip to content

Commit

Permalink
Fix isMultiple not handling multi-word flags (#150)
Browse files Browse the repository at this point in the history
  • Loading branch information
ulken committed May 11, 2020
1 parent e3301ed commit e08eb4d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
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

0 comments on commit e08eb4d

Please sign in to comment.