diff options
-rw-r--r-- | packages/contracts/test/global_hooks.ts | 4 | ||||
-rw-r--r-- | packages/dev-utils/src/coverage.ts | 17 | ||||
-rw-r--r-- | packages/dev-utils/src/index.ts | 2 | ||||
-rw-r--r-- | packages/dev-utils/src/web3_factory.ts | 4 |
4 files changed, 16 insertions, 11 deletions
diff --git a/packages/contracts/test/global_hooks.ts b/packages/contracts/test/global_hooks.ts index b29e171d7..0440c871d 100644 --- a/packages/contracts/test/global_hooks.ts +++ b/packages/contracts/test/global_hooks.ts @@ -1,8 +1,8 @@ -import { getCoverageSubproviderSingleton } from '@0xproject/dev-utils'; +import { coverage } from '@0xproject/dev-utils'; after('generate coverage report', async () => { if (process.env.SOLIDITY_COVERAGE) { - const coverageSubprovider = getCoverageSubproviderSingleton(); + const coverageSubprovider = coverage.getCoverageSubproviderSingleton(); await coverageSubprovider.writeCoverageAsync(); } }); diff --git a/packages/dev-utils/src/coverage.ts b/packages/dev-utils/src/coverage.ts index b39fa5de4..db87e2285 100644 --- a/packages/dev-utils/src/coverage.ts +++ b/packages/dev-utils/src/coverage.ts @@ -3,12 +3,17 @@ import * as _ from 'lodash'; let coverageSubprovider: CoverageSubprovider; -export function getCoverageSubproviderSingleton(): CoverageSubprovider { - if (_.isUndefined(coverageSubprovider)) { +export const coverage = { + getCoverageSubproviderSingleton(): CoverageSubprovider { + if (_.isUndefined(coverageSubprovider)) { + coverageSubprovider = coverage._getCoverageSubprovider(); + } + return coverageSubprovider; + }, + _getCoverageSubprovider(): CoverageSubprovider { const artifactsPath = './src/artifacts'; const contractsPath = './src/contracts'; const networkId = 50; - coverageSubprovider = new CoverageSubprovider(artifactsPath, contractsPath, networkId); - } - return coverageSubprovider; -} + return new CoverageSubprovider(artifactsPath, contractsPath, networkId); + }, +}; diff --git a/packages/dev-utils/src/index.ts b/packages/dev-utils/src/index.ts index 61e9bcfa2..72d538e5d 100644 --- a/packages/dev-utils/src/index.ts +++ b/packages/dev-utils/src/index.ts @@ -1,4 +1,4 @@ export { BlockchainLifecycle } from './blockchain_lifecycle'; export { web3Factory } from './web3_factory'; export { constants as devConstants } from './constants'; -export { getCoverageSubproviderSingleton } from './coverage'; +export { coverage } from './coverage'; diff --git a/packages/dev-utils/src/web3_factory.ts b/packages/dev-utils/src/web3_factory.ts index 200670c3b..74deec7b1 100644 --- a/packages/dev-utils/src/web3_factory.ts +++ b/packages/dev-utils/src/web3_factory.ts @@ -12,7 +12,7 @@ import * as _ from 'lodash'; import * as process from 'process'; import { constants } from './constants'; -import { getCoverageSubproviderSingleton } from './coverage'; +import { coverage } from './coverage'; // HACK: web3 leaks XMLHttpRequest into the global scope and causes requests to hang // because they are using the wrong XHR package. @@ -36,7 +36,7 @@ export const web3Factory = { getRpcProvider(config: Web3Config = {}): Web3.Provider { const provider = new ProviderEngine(); if (process.env.SOLIDITY_COVERAGE) { - provider.addProvider(getCoverageSubproviderSingleton()); + provider.addProvider(coverage.getCoverageSubproviderSingleton()); } const hasAddresses = _.isUndefined(config.hasAddresses) || config.hasAddresses; if (!hasAddresses) { |