aboutsummaryrefslogtreecommitdiffstats
path: root/packages/dev-utils/src/env.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/dev-utils/src/env.ts')
-rw-r--r--packages/dev-utils/src/env.ts24
1 files changed, 24 insertions, 0 deletions
diff --git a/packages/dev-utils/src/env.ts b/packages/dev-utils/src/env.ts
new file mode 100644
index 000000000..114dbf4a8
--- /dev/null
+++ b/packages/dev-utils/src/env.ts
@@ -0,0 +1,24 @@
+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;
+ const envVarValue = process.env[key];
+ if (envVarValue === 'true') {
+ isTrue = true;
+ } else if (envVarValue === 'false' || _.isUndefined(envVarValue)) {
+ 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;
+ },
+};