Skip to content

Commit

Permalink
fix: validate ncu-ci args (#411)
Browse files Browse the repository at this point in the history
  • Loading branch information
Alicia Lopez committed May 14, 2020
1 parent 9643904 commit 58bdf05
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions bin/ncu-ci
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ const Request = require('../lib/request');
const CLI = require('../lib/cli');
const yargs = require('yargs');

const commandKeys = [
'rate',
'walk',
'url',
'pr',
'commit'
];

// eslint-disable-next-line no-unused-vars
const argv = yargs
.command({
Expand Down Expand Up @@ -115,13 +123,20 @@ const argv = yargs
default: false,
describe: 'Write the results as markdown to clipboard'
})
.option('json', {
.option('json <path>', {
type: 'string',
describe: 'Write the results as json to the path'
describe: 'Write the results as json to <path>'
})
.option('markdown', {
.option('markdown <path>', {
type: 'string',
describe: 'Write the results as markdown to the path'
describe: 'Write the results as markdown to <path>'
}).check(argv => {
if (argv.markdown && commandKeys.includes(argv.markdown)) {
throw new Error('--markdown <path> did not specify a valid path');
} else if (argv.json && commandKeys.includes(argv.json)) {
throw new Error('--json <path> did not specify a valid path');
}
return true;
})
.help()
.argv;
Expand Down

0 comments on commit 58bdf05

Please sign in to comment.