Skip to content

Commit ffe80f4

Browse files
authored
Merge of #2156
2 parents 7b38b46 + 08358a5 commit ffe80f4

File tree

3 files changed

+19
-11
lines changed

3 files changed

+19
-11
lines changed

gateway-contracts/tasks/utils/loadVariables.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,19 @@ import path from "path";
55
import { ADDRESSES_DIR, GATEWAY_ADDRESSES_ENV_FILE_NAME } from "../../hardhat.config";
66
import { 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
109
export 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
1921
export function getRequiredAddressEnvVar(name: string): string {
2022
const addressEnvVarName = pascalCaseToAddressEnvVar(name);
2123
return getRequiredEnvVar(addressEnvVarName);

host-contracts/tasks/utils/loadVariables.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,16 @@ import path from 'path';
44

55
import { ADDRESSES_DIR, HOST_ADDRESSES_ENV_FILE_NAME } from '../../hardhat.config';
66

7-
// Get the required environment variable, throw an error if it's not set
8-
// We only check if the variable is set, not if it's empty
7+
// Get the required environment variable, throw an error if it's not set or empty
98
export function getRequiredEnvVar(name: string): string {
109
if (!(name in process.env)) {
1110
throw new Error(`"${name}" env variable is not set`);
1211
}
13-
return process.env[name]!;
12+
const value = process.env[name]!;
13+
if (value.trim() === '') {
14+
throw new Error(`"${name}" env variable is set but empty`);
15+
}
16+
return value;
1417
}
1518

1619
// Load the addresses as environment variables from the env file

library-solidity/tasks/utils/loadVariables.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,16 @@ import path from 'path';
55
const ADDRESSES_DIR = path.resolve(__dirname, '../../fhevmTemp/addresses');
66
const HOST_ADDRESSES_ENV_FILE_NAME = '.env.host';
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
109
export 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

1720
// Load the addresses as environment variables from the env file

0 commit comments

Comments
 (0)