From 425fab1a35ad2503490d7426c8e4b849718ae81e Mon Sep 17 00:00:00 2001 From: Shelley Vohr Date: Wed, 6 May 2020 09:20:58 -0700 Subject: [PATCH] fix: validate ncu-ci args --- bin/ncu-ci | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/bin/ncu-ci b/bin/ncu-ci index 098f3c4b..725eec7f 100755 --- a/bin/ncu-ci +++ b/bin/ncu-ci @@ -23,6 +23,14 @@ const Request = require('../lib/request'); const CLI = require('../lib/cli'); const yargs = require('yargs'); +const optionKeys = [ + 'rate', + 'walk', + 'url', + 'pr', + 'commit', +] + // eslint-disable-next-line no-unused-vars const argv = yargs .command({ @@ -115,13 +123,20 @@ const argv = yargs default: false, describe: 'Write the results as markdown to clipboard' }) - .option('json', { + .option('json ', { type: 'string', - describe: 'Write the results as json to the path' + describe: 'Write the results as json to ' }) - .option('markdown', { + .option('markdown ', { type: 'string', - describe: 'Write the results as markdown to the path' + describe: 'Write the results as markdown to ' + }).check(argv => { + if (argv.markdown && optionKeys.includes(argv.markdown)) { + throw new Error('--markdown did not specify a valid path'); + } else if (argv.json && optionKeys.includes(argv.json)) { + throw new Error('--json did not specify a valid path'); + } + return true; }) .help() .argv;