remove custom option validation

Was trying to get a bit too fancy and show an error message if the user didn’t provide a valid value. Instead, if they use `—node` and the value is not a valid option, `vm` will be the default.
This commit is contained in:
emizzle 2018-09-14 15:23:38 +10:00
parent 60703b86c5
commit 7658818571
1 changed files with 2 additions and 6 deletions

View File

@ -262,23 +262,19 @@ class Cmd {
}
test() {
const urlRegexExp = /^(vm|embark|((ws|https?):\/\/([a-zA-Z0-9_.-]*):?([0-9]*)?))$/i;
program
.command('test [file]')
.option('-n , --node <node>', __('Node to connect to. Valid values are ["vm", "embark", "<custom node endpoint>"]: \n') +
' vm - ' + __('Starts an Ethereum simulator (ganache) and runs the tests using the simulator') + '\n' +
' embark - ' + __('Uses the node associated with an already running embark process') + '\n' +
' ' + __('<custom node endpoint> - Connects to a running node available at the end point and uses it to run the tests'),
/^(vm|embark|((ws|https?):\/\/([a-zA-Z0-9_.-]*):?([0-9]*)?))$/i, null)
urlRegexExp, 'vm')
.option('-d , --gasDetails', __('When set, will print the gas cost for each contract deploy'))
.option('--locale [locale]', __('language to use (default: en)'))
.option('--loglevel [loglevel]', __('level of logging to display') + ' ["error", "warn", "info", "debug", "trace"]', /^(error|warn|info|debug|trace)$/i, 'warn')
.description(__('run tests'))
.action(function(file, options) {
if(options.node === null){
console.log(__('Invalid value for option --node. Valid values are ["vm", "embark", "<custom node endpoint>"]".').red);
console.log(options.optionHelp());
process.exit(1);
}
checkDeps();
i18n.setOrDetectLocale(options.locale);
embark.runTests({file, loglevel: options.loglevel, gasDetails: options.gasDetails, node: options.node});