diff options
Diffstat (limited to 'packages/dev-utils')
-rw-r--r-- | packages/dev-utils/src/env.ts | 19 |
1 files changed, 19 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..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; + }, +}; |