OffchainLabs / arbitrum-tutorials

Get started developing on Arbitrum
455 stars 280 forks source link

Add possibility to use a global .env file in the root of the project #96

Closed TucksonDev closed 1 year ago

TucksonDev commented 1 year ago

This change allows us to have a .env file in the root of the project with all common environment variables. However, it also allows for local .env files in each package (it will override the variable from the root .env file if present.

For reference, there are usually 5 calls to dotenv.config() within the execution of a script:

  1. From the package's hardhat.config.js => arb-shared-dependencies/index.js => arb-shared-dependencies/hardhat.config.js => dotenv.config()
  2. From the package's hardhat.config.js => arb-shared-dependencies/index.js => dotenv.config({path})
  3. Again, from the package's hardhat.config.js => arb-shared-dependencies/index.js => arb-shared-dependencies/hardhat.config.js => dotenv.config()
  4. Again, from the package's hardhat.config.js => arb-shared-dependencies/index.js => dotenv.config({path})
  5. From the script being executed => dotenv.config()