File tree Expand file tree Collapse file tree 2 files changed +13
-8
lines changed
gateway-contracts/tasks/utils
host-contracts/tasks/utils Expand file tree Collapse file tree 2 files changed +13
-8
lines changed Original file line number Diff line number Diff line change @@ -5,17 +5,19 @@ import path from "path";
55import { ADDRESSES_DIR , GATEWAY_ADDRESSES_ENV_FILE_NAME } from "../../hardhat.config" ;
66import { pascalCaseToAddressEnvVar } from "../utils" ;
77
8- // Get the required environment variable, throw an error if it's not set
9- // We only check if the variable is set, not if it's empty
8+ // Get the required environment variable, throw an error if it's not set or empty
109export function getRequiredEnvVar ( name : string ) : string {
1110 if ( ! ( name in process . env ) ) {
1211 throw new Error ( `"${ name } " env variable is not set` ) ;
1312 }
14- return process . env [ name ] ! ;
13+ const value = process . env [ name ] ! ;
14+ if ( value . trim ( ) === "" ) {
15+ throw new Error ( `"${ name } " env variable is set but empty` ) ;
16+ }
17+ return value ;
1518}
1619
17- // Get the required address from the environment variable, throw an error if it's not set
18- // We only check if the variable is set, not if it's empty
20+ // Get the required address from the environment variable, throw an error if it's not set or empty
1921export function getRequiredAddressEnvVar ( name : string ) : string {
2022 const addressEnvVarName = pascalCaseToAddressEnvVar ( name ) ;
2123 return getRequiredEnvVar ( addressEnvVarName ) ;
Original file line number Diff line number Diff line change 1- // Get the required environment variable, throw an error if it's not set
2- // We only check if the variable is set, not if it's empty
1+ // Get the required environment variable, throw an error if it's not set or empty
32export function getRequiredEnvVar ( name : string ) : string {
43 if ( ! ( name in process . env ) ) {
54 throw new Error ( `"${ name } " env variable is not set` ) ;
65 }
7- return process . env [ name ] ! ;
6+ const value = process . env [ name ] ! ;
7+ if ( value . trim ( ) === '' ) {
8+ throw new Error ( `"${ name } " env variable is set but empty` ) ;
9+ }
10+ return value ;
811}
You can’t perform that action at this time.
0 commit comments