aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2018-03-13 22:19:31 +0800
committerLeonid Logvinov <logvinov.leon@gmail.com>2018-03-13 22:19:31 +0800
commita9db0e8ebe1360cf521302691998ef1f98e2dc51 (patch)
tree683ae243e2690ade19833d4986192d8a6e760144
parenta0791455e11022d16dbffba9b7080010a05d6522 (diff)
downloaddexon-0x-contracts-a9db0e8ebe1360cf521302691998ef1f98e2dc51.tar
dexon-0x-contracts-a9db0e8ebe1360cf521302691998ef1f98e2dc51.tar.gz
dexon-0x-contracts-a9db0e8ebe1360cf521302691998ef1f98e2dc51.tar.bz2
dexon-0x-contracts-a9db0e8ebe1360cf521302691998ef1f98e2dc51.tar.lz
dexon-0x-contracts-a9db0e8ebe1360cf521302691998ef1f98e2dc51.tar.xz
dexon-0x-contracts-a9db0e8ebe1360cf521302691998ef1f98e2dc51.tar.zst
dexon-0x-contracts-a9db0e8ebe1360cf521302691998ef1f98e2dc51.zip
Properly and consistently parse ENV vars
-rw-r--r--packages/contracts/test/global_hooks.ts4
-rw-r--r--packages/dev-utils/src/env.ts5
-rw-r--r--packages/dev-utils/src/index.ts1
-rw-r--r--packages/dev-utils/src/web3_factory.ts7
4 files changed, 9 insertions, 8 deletions
diff --git a/packages/contracts/test/global_hooks.ts b/packages/contracts/test/global_hooks.ts
index 0440c871d..089521d94 100644
--- a/packages/contracts/test/global_hooks.ts
+++ b/packages/contracts/test/global_hooks.ts
@@ -1,7 +1,7 @@
-import { coverage } from '@0xproject/dev-utils';
+import { coverage, env, EnvVars } from '@0xproject/dev-utils';
after('generate coverage report', async () => {
- if (process.env.SOLIDITY_COVERAGE) {
+ if (env.parseBoolean(EnvVars.SolidityCoverage)) {
const coverageSubprovider = coverage.getCoverageSubproviderSingleton();
await coverageSubprovider.writeCoverageAsync();
}
diff --git a/packages/dev-utils/src/env.ts b/packages/dev-utils/src/env.ts
index 6f8b1c5f8..114dbf4a8 100644
--- a/packages/dev-utils/src/env.ts
+++ b/packages/dev-utils/src/env.ts
@@ -1,6 +1,11 @@
import * as _ from 'lodash';
import * as process from 'process';
+export enum EnvVars {
+ SolidityCoverage = 'SOLIDITY_COVERAGE',
+ VerboseGanache = 'VERBOSE_GANACHE',
+}
+
export const env = {
parseBoolean(key: string): boolean {
let isTrue: boolean;
diff --git a/packages/dev-utils/src/index.ts b/packages/dev-utils/src/index.ts
index 72d538e5d..2ff2a2238 100644
--- a/packages/dev-utils/src/index.ts
+++ b/packages/dev-utils/src/index.ts
@@ -2,3 +2,4 @@ export { BlockchainLifecycle } from './blockchain_lifecycle';
export { web3Factory } from './web3_factory';
export { constants as devConstants } from './constants';
export { coverage } from './coverage';
+export { env, EnvVars } from './env';
diff --git a/packages/dev-utils/src/web3_factory.ts b/packages/dev-utils/src/web3_factory.ts
index 3e4b39686..6435f0f9a 100644
--- a/packages/dev-utils/src/web3_factory.ts
+++ b/packages/dev-utils/src/web3_factory.ts
@@ -13,7 +13,7 @@ import * as process from 'process';
import { constants } from './constants';
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
// because they are using the wrong XHR package.
@@ -27,11 +27,6 @@ export interface Web3Config {
shouldUseInProcessGanache?: boolean; // default: false
}
-enum EnvVars {
- SolidityCoverage = 'SOLIDITY_COVERAGE',
- VerboseGanache = 'VERBOSE_GANACHE',
-}
-
export const web3Factory = {
create(config: Web3Config = {}): Web3 {
const provider = this.getRpcProvider(config);