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(cli): error on conflicting options #72

Merged
merged 2 commits into from
Feb 20, 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
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