Skip to content

Commit

Permalink
fix(cli): conflicting arguments will error (#72)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: CLI may show an error when arguments
conflict and the order of short and long options was reversed
to be more descriptive on CLI options errors.
  • Loading branch information
lirantal committed Feb 20, 2020
1 parent 9c79b18 commit 3e0eb59
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
22 changes: 22 additions & 0 deletions packages/lockfile-lint/__tests__/cli.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,26 @@ describe('CLI tests', () => {
done()
})
})

test('Providing conflicting arguments should display an error', done => {
const process = childProcess.spawn(cliExecPath, [
'--type',
'yarn',
'--path',
'__tests__/fixtures/yarn-only-http.lock',
'--validate-https',
'--allowed-schemes',
'https:'
])

let output = ''
process.stderr.on('data', chunk => {
output += chunk
})

process.stderr.on('close', _ => {
expect(output.indexOf('Arguments o and validate-https are mutually exclusive')).not.toBe(-1)
done()
})
})
})
3 changes: 2 additions & 1 deletion packages/lockfile-lint/src/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ const argv = yargs
o: {
alias: ['allowed-schemes'],
type: 'array',
describe: 'validates a whitelist of allowed schemes to be used for resources in the lockfile'
describe: 'validates a whitelist of allowed schemes to be used for resources in the lockfile',
conflicts: ['validate-https', 's']
}
})
.example('lockfile-lint --path yarn.lock --validate-https')
Expand Down

0 comments on commit 3e0eb59

Please sign in to comment.