2022-09-06 03:51:28 +00:00
|
|
|
/**
|
2022-09-10 21:55:53 +00:00
|
|
|
* External dependencies
|
2022-09-06 03:51:28 +00:00
|
|
|
*/
|
2022-09-10 21:55:53 +00:00
|
|
|
import { Logger } from 'cli-core/src/logger';
|
|
|
|
|
2022-09-06 03:51:28 +00:00
|
|
|
export const getEnvVar = ( varName: string, isRequired = false ) => {
|
|
|
|
const value = process.env[ varName ];
|
|
|
|
|
|
|
|
if ( value === undefined && isRequired ) {
|
|
|
|
Logger.error(
|
|
|
|
`You need to provide a value for ${ varName } in your environment either via an environment variable or the .env file.`
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return value || '';
|
|
|
|
};
|