Stop printing help on error

This commit is contained in:
Leonid Logvinov
2018-03-15 16:29:55 +01:00
parent 02ede26893
commit 3c36135d6c
2 changed files with 16 additions and 2 deletions

View File

@@ -10,6 +10,7 @@ import * as yargs from 'yargs';
import { commands } from './commands';
import { constants } from './utils/constants';
import { consoleReporter } from './utils/error_reporter';
import { CliOptions, CompilerOptions, DeployerOptions } from './utils/types';
const DEFAULT_OPTIMIZER_ENABLED = false;
@@ -142,12 +143,12 @@ function deployCommandBuilder(yargsInstance: any) {
default: DEFAULT_CONTRACTS_LIST,
description: 'comma separated list of contracts to compile',
})
.command('compile', 'compile contracts', identityCommandBuilder, onCompileCommandAsync)
.command('compile', 'compile contracts', identityCommandBuilder, consoleReporter(onCompileCommandAsync))
.command(
'deploy',
'deploy a single contract with provided arguments',
deployCommandBuilder,
onDeployCommandAsync,
consoleReporter(onDeployCommandAsync),
)
.help().argv;
})();

View File

@@ -0,0 +1,13 @@
import { logUtils } from '@0xproject/utils';
export function consoleReporter<T>(asyncFn: (arg: T) => Promise<void>) {
const noThrowFnAsync = async (arg: T) => {
try {
const result = await asyncFn(arg);
return result;
} catch (err) {
logUtils.log(`${err}`);
}
};
return noThrowFnAsync;
}