From 4cba1ff5c7475e004a447cca489b0fc0ac1a05ce 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..8037a26d 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 commandKeys = [ + '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 && commandKeys.includes(argv.markdown)) { + throw new Error('--markdown did not specify a valid path'); + } else if (argv.json && commandKeys.includes(argv.json)) { + throw new Error('--json did not specify a valid path'); + } + return true; }) .help() .argv;