Skip to content

Commit

Permalink
fix: parse array rather than string, so that quotes are safe (yargs#993)
Browse files Browse the repository at this point in the history
  • Loading branch information
bcoe committed Oct 21, 2017
1 parent 0684741 commit c351685
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lib/command.js
Expand Up @@ -318,15 +318,16 @@ module.exports = function command (yargs, usage, validation) {

const unparsed = []
Object.keys(positionalMap).forEach((key) => {
[].push.apply(unparsed, positionalMap[key].map((value) => {
return `--${key} ${value}`
}))
positionalMap[key].map((value) => {
unparsed.push(`--${key}`)
unparsed.push(value)
})
})

// short-circuit parse.
if (!unparsed.length) return

const parsed = Parser.detailed(unparsed.join(' '), options)
const parsed = Parser.detailed(unparsed, options)

if (parsed.error) {
yargs.getUsageInstance().fail(parsed.error.message, parsed.error)
Expand Down

0 comments on commit c351685

Please sign in to comment.