From 12f19e082ad67cfbb6b11214673a226f5e79d811 Mon Sep 17 00:00:00 2001 From: Scott Motte Date: Thu, 3 Feb 2022 19:20:48 -0800 Subject: [PATCH 1/3] Bump dotenv@16.0.0 --- package-lock.json | 14 +++++++------- package.json | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/package-lock.json b/package-lock.json index 77e7ee1..4b9cd94 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,7 @@ "license": "BSD-2-Clause", "devDependencies": { "@types/node": "^17.0.8", - "dotenv": "^15.0.0", + "dotenv": "^16.0.0", "lab": "^14.3.4", "should": "^11.2.1", "standard": "^16.0.4", @@ -671,9 +671,9 @@ } }, "node_modules/dotenv": { - "version": "15.0.0", - "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-15.0.0.tgz", - "integrity": "sha512-/l1sXXm79ry34KwwS0y4oVZjB468iw/6u9g1W26dtexKcIJAnVL2pMF+hxQwzZ7LutxOwEgtym9eIxvX33CMKg==", + "version": "16.0.0", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.0.0.tgz", + "integrity": "sha512-qD9WU0MPM4SWLPJy/r2Be+2WgQj8plChsyrCNQzW/0WjvcJQiKQJ9mH3ZgB3fxbUUxgc/11ZJ0Fi5KiimWGz2Q==", "dev": true, "engines": { "node": ">=12" @@ -4680,9 +4680,9 @@ } }, "dotenv": { - "version": "15.0.0", - "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-15.0.0.tgz", - "integrity": "sha512-/l1sXXm79ry34KwwS0y4oVZjB468iw/6u9g1W26dtexKcIJAnVL2pMF+hxQwzZ7LutxOwEgtym9eIxvX33CMKg==", + "version": "16.0.0", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.0.0.tgz", + "integrity": "sha512-qD9WU0MPM4SWLPJy/r2Be+2WgQj8plChsyrCNQzW/0WjvcJQiKQJ9mH3ZgB3fxbUUxgc/11ZJ0Fi5KiimWGz2Q==", "dev": true }, "emoji-regex": { diff --git a/package.json b/package.json index 04e377f..5a969ea 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,7 @@ "license": "BSD-2-Clause", "devDependencies": { "@types/node": "^17.0.8", - "dotenv": "^15.0.0", + "dotenv": "^16.0.0", "lab": "^14.3.4", "should": "^11.2.1", "standard": "^16.0.4", From 2fa1e4bde697488ccf0785f822be832f6b865515 Mon Sep 17 00:00:00 2001 From: Scott Motte Date: Thu, 3 Feb 2022 19:27:40 -0800 Subject: [PATCH 2/3] Update README and CHANGELOG --- CHANGELOG.md | 11 ++++++++- README.md | 68 ++++++++++++++++++++++------------------------------ 2 files changed, 39 insertions(+), 40 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 99f2338..1877b5a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,8 +2,17 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. -## [Unreleased](https://github.com/motdotla/dotenv-expand/compare/v6.0.1...master) +## [Unreleased](https://github.com/motdotla/dotenv-expand/compare/v8.0.0...master) +## [8.0.0](https://github.com/motdotla/dotenv-expand/compare/v7.0.0...v8.0.0) (2022-02-03) + +### Changed + +- _Breaking:_ Bump to `v16.0.0` of dotenv + +### Added + +- Preload support 🎉 ([#31](https://github.com/motdotla/dotenv-expand/pull/31)) ## [7.0.0](https://github.com/motdotla/dotenv-expand/compare/v6.0.1...v7.0.0) (2022-01-17) diff --git a/README.md b/README.md index 4480296..83d3b25 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,6 @@ dotenv-expand is your tool. ```bash # Install locally (recommended) -npm install dotenv --save npm install dotenv-expand --save ``` @@ -27,24 +26,17 @@ Or installing with yarn? `yarn add dotenv-expand` ## Usage -Usage is a cinch! - -### 1. Create a .env file with variable expansions in the root directory of your project +Create a `.env` file in the root of your project: ```dosini -# .env file -# -# Add environment-specific variables on new lines in the form of NAME=VALUE -# -PASSWORD=s1mpl3 -DB_HOST=localhost -DB_USER=root +PASSWORD="s1mpl3" DB_PASS=$PASSWORD + ``` -### 2. As early as possible in your application, import dotenv and expand with dotenv-expand +As early as possible in your application, import and configure dotenv and then expand dotenv: -```js +```javascript var dotenv = require('dotenv') var dotenvExpand = require('dotenv-expand') @@ -54,9 +46,31 @@ dotenvExpand.expand(myEnv) console.log(process.env) ``` -### 3. That's it! 👏 +That's it. `process.env` now has the expanded keys and values you defined in your `.env` file. + +### Preload + +You can use the `--require` (`-r`) [command line option](https://nodejs.org/api/cli.html#cli_r_require_module) to preload dotenv & dotenv-extend. By doing this, you do not need to require and load dotenv or dotenv-extend in your application code. This is the preferred approach when using `import` instead of `require`. + +```bash +$ node -r dotenv-extend/config your_script.js +``` + +The configuration options below are supported as command line arguments in the format `dotenv_config_