Properly and consistently parse ENV vars

This commit is contained in:
Leonid Logvinov 2018-03-13 15:19:31 +01:00
parent a0791455e1
commit a9db0e8ebe
No known key found for this signature in database
GPG Key ID: 0DD294BFDE8C95D4
4 changed files with 9 additions and 8 deletions

View File

@ -1,7 +1,7 @@
import { coverage } from '@0xproject/dev-utils'; import { coverage, env, EnvVars } from '@0xproject/dev-utils';
after('generate coverage report', async () => { after('generate coverage report', async () => {
if (process.env.SOLIDITY_COVERAGE) { if (env.parseBoolean(EnvVars.SolidityCoverage)) {
const coverageSubprovider = coverage.getCoverageSubproviderSingleton(); const coverageSubprovider = coverage.getCoverageSubproviderSingleton();
await coverageSubprovider.writeCoverageAsync(); await coverageSubprovider.writeCoverageAsync();
} }

View File

@ -1,6 +1,11 @@
import * as _ from 'lodash'; import * as _ from 'lodash';
import * as process from 'process'; import * as process from 'process';
export enum EnvVars {
SolidityCoverage = 'SOLIDITY_COVERAGE',
VerboseGanache = 'VERBOSE_GANACHE',
}
export const env = { export const env = {
parseBoolean(key: string): boolean { parseBoolean(key: string): boolean {
let isTrue: boolean; let isTrue: boolean;

View File

@ -2,3 +2,4 @@ export { BlockchainLifecycle } from './blockchain_lifecycle';
export { web3Factory } from './web3_factory'; export { web3Factory } from './web3_factory';
export { constants as devConstants } from './constants'; export { constants as devConstants } from './constants';
export { coverage } from './coverage'; export { coverage } from './coverage';
export { env, EnvVars } from './env';

View File

@ -13,7 +13,7 @@ import * as process from 'process';
import { constants } from './constants'; import { constants } from './constants';
import { coverage } from './coverage'; import { coverage } from './coverage';
import { env } from './env'; import { env, EnvVars } from './env';
// HACK: web3 leaks XMLHttpRequest into the global scope and causes requests to hang // HACK: web3 leaks XMLHttpRequest into the global scope and causes requests to hang
// because they are using the wrong XHR package. // because they are using the wrong XHR package.
@ -27,11 +27,6 @@ export interface Web3Config {
shouldUseInProcessGanache?: boolean; // default: false shouldUseInProcessGanache?: boolean; // default: false
} }
enum EnvVars {
SolidityCoverage = 'SOLIDITY_COVERAGE',
VerboseGanache = 'VERBOSE_GANACHE',
}
export const web3Factory = { export const web3Factory = {
create(config: Web3Config = {}): Web3 { create(config: Web3Config = {}): Web3 {
const provider = this.getRpcProvider(config); const provider = this.getRpcProvider(config);