aboutsummaryrefslogtreecommitdiffstats
path: root/packages/dev-utils/src/env.ts
blob: 7e46a5f89ef437352afca6ccd2766839ad748913 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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;
    },
};