From 870995933a60b67af03b3f42a2aed169d33bd87f Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Mon, 12 Mar 2018 03:35:11 +0100 Subject: Remove redundant Date.now() --- packages/dev-utils/src/env.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 packages/dev-utils/src/env.ts (limited to 'packages/dev-utils/src/env.ts') 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; + }, +}; -- cgit v1.2.3 From e4740961199ee6b34ad32dd242e0081afbb41a69 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Mon, 12 Mar 2018 12:53:51 +0100 Subject: Fix a typo in handling env variables --- packages/dev-utils/src/env.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'packages/dev-utils/src/env.ts') diff --git a/packages/dev-utils/src/env.ts b/packages/dev-utils/src/env.ts index 7e46a5f89..6f8b1c5f8 100644 --- a/packages/dev-utils/src/env.ts +++ b/packages/dev-utils/src/env.ts @@ -4,10 +4,10 @@ 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') { + const envVarValue = process.env[key]; + if (envVarValue === 'true') { isTrue = true; - } else if (process.env.SOLIDITY_COVERAGE === 'false' || _.isUndefined(process.env.SOLIDITY_COVERAGE)) { + } else if (envVarValue === 'false' || _.isUndefined(envVarValue)) { isTrue = false; } else { throw new Error( -- cgit v1.2.3 From a9db0e8ebe1360cf521302691998ef1f98e2dc51 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Tue, 13 Mar 2018 15:19:31 +0100 Subject: Properly and consistently parse ENV vars --- packages/dev-utils/src/env.ts | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'packages/dev-utils/src/env.ts') 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; -- cgit v1.2.3