diff options
author | Leonid Logvinov <logvinov.leon@gmail.com> | 2018-03-12 10:35:11 +0800 |
---|---|---|
committer | Leonid Logvinov <logvinov.leon@gmail.com> | 2018-03-12 10:37:30 +0800 |
commit | 870995933a60b67af03b3f42a2aed169d33bd87f (patch) | |
tree | 2c8c583434080413dbb8aede8de515d5ed7e05ef /packages | |
parent | d6c2e47bbd099f380c8fd4790d6d7be17d3532e5 (diff) | |
download | dexon-0x-contracts-870995933a60b67af03b3f42a2aed169d33bd87f.tar dexon-0x-contracts-870995933a60b67af03b3f42a2aed169d33bd87f.tar.gz dexon-0x-contracts-870995933a60b67af03b3f42a2aed169d33bd87f.tar.bz2 dexon-0x-contracts-870995933a60b67af03b3f42a2aed169d33bd87f.tar.lz dexon-0x-contracts-870995933a60b67af03b3f42a2aed169d33bd87f.tar.xz dexon-0x-contracts-870995933a60b67af03b3f42a2aed169d33bd87f.tar.zst dexon-0x-contracts-870995933a60b67af03b3f42a2aed169d33bd87f.zip |
Remove redundant Date.now()
Diffstat (limited to 'packages')
-rw-r--r-- | packages/dev-utils/src/env.ts | 19 | ||||
-rw-r--r-- | packages/sol-cov/src/collect_coverage_entries.ts (renamed from packages/sol-cov/src/instrument_solidity.ts) | 1 | ||||
-rw-r--r-- | packages/sol-cov/src/coverage_manager.ts | 2 |
3 files changed, 20 insertions, 2 deletions
diff --git a/packages/dev-utils/src/env.ts b/packages/dev-utils/src/env.ts new file mode 100644 index 000000000..7e46a5f89 --- /dev/null +++ b/packages/dev-utils/src/env.ts @@ -0,0 +1,19 @@ +import * as _ from 'lodash'; +import * as process from 'process'; + +export const env = { + parseBoolean(key: string): boolean { + let isTrue: boolean; + const envVarvalue = process.env[key]; + if (process.env.SOLIDITY_COVERAGE === 'true') { + isTrue = true; + } else if (process.env.SOLIDITY_COVERAGE === 'false' || _.isUndefined(process.env.SOLIDITY_COVERAGE)) { + isTrue = false; + } else { + throw new Error( + `Failed to parse ENV variable ${key} as boolean. Please make sure it's either true or false. Defaults to false`, + ); + } + return isTrue; + }, +}; diff --git a/packages/sol-cov/src/instrument_solidity.ts b/packages/sol-cov/src/collect_coverage_entries.ts index 163e3c7b9..d29fa2c37 100644 --- a/packages/sol-cov/src/instrument_solidity.ts +++ b/packages/sol-cov/src/collect_coverage_entries.ts @@ -11,7 +11,6 @@ import { getLocationByOffset } from './source_maps'; const coverageEntriesBySourceHash: { [sourceHash: string]: CoverageEntriesDescription } = {}; export const collectCoverageEntries = (contractSource: string, fileName: string) => { - const time = Date.now(); const sourceHash = ethUtil.sha3(contractSource).toString('hex'); if (_.isUndefined(coverageEntriesBySourceHash[sourceHash])) { const ast = SolidityParser.parse(contractSource); diff --git a/packages/sol-cov/src/coverage_manager.ts b/packages/sol-cov/src/coverage_manager.ts index 870dc2bdb..4ca6b0ec8 100644 --- a/packages/sol-cov/src/coverage_manager.ts +++ b/packages/sol-cov/src/coverage_manager.ts @@ -4,8 +4,8 @@ import * as _ from 'lodash'; import * as path from 'path'; import { collectContractsData } from './collect_contract_data'; +import { collectCoverageEntries } from './collect_coverage_entries'; import { constants } from './constants'; -import { collectCoverageEntries } from './instrument_solidity'; import { parseSourceMap } from './source_maps'; import { BranchCoverage, |