Skip to content

Commit

Permalink
Merge branch 'master' into yeti-or.fix-build
Browse files Browse the repository at this point in the history
  • Loading branch information
motdotla authored Feb 4, 2022
2 parents 9442a00 + a2f1279 commit cc198df
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 51 deletions.
11 changes: 10 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
69 changes: 30 additions & 39 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,32 +19,24 @@ dotenv-expand is your tool.

```bash
# Install locally (recommended)
npm install dotenv --save
npm install dotenv-expand --save
```

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')

Expand All @@ -54,9 +46,32 @@ 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-
. By doing this, you do not need to require and load dotenv or dotenv-expand in your application code. This is the preferred approach when using `import` instead of `require`.

```bash
$ node -r dotenv-expand/config your_script.js
```

The configuration options below are supported as command line arguments in the format `dotenv_config_<option>=value`

```bash
$ node -r dotenv-expand/config your_script.js dotenv_config_path=/custom/path/to/your/env/vars
```

Additionally, you can use environment variables to set configuration options. Command line arguments will precede these.

```bash
$ DOTENV_CONFIG_<OPTION>=value node -r dotenv-expand/config your_script.js
```

`process.env` now has the expanded keys and values you defined in your `.env` file.
```bash
$ DOTENV_CONFIG_ENCODING=latin1 node -r dotenv-expand/config your_script.js dotenv_config_path=/custom/path/to/.env
```

## Examples

Expand Down Expand Up @@ -129,30 +144,6 @@ See [CONTRIBUTING.md](CONTRIBUTING.md)

See [CHANGELOG.md](CHANGELOG.md)

### Preload

You can use the `--require` (`-r`) [command line option](https://nodejs.org/api/cli.html#cli_r_require_module) to preload dotenv & dotenv-expand. By doing this, you do not need to require and load dotenv or dotenv-expand in your application code. This is the preferred approach when using `import` instead of `require`.

```bash
$ node -r dotenv-expand/config your_script.js
```

The configuration options below are supported as command line arguments in the format `dotenv_config_<option>=value`

```bash
$ node -r dotenv-expand/config your_script.js dotenv_config_path=/custom/path/to/your/env/vars
```

Additionally, you can use environment variables to set configuration options. Command line arguments will precede these.

```bash
$ DOTENV_CONFIG_<OPTION>=value node -r dotenv-expand/config your_script.js
```

```bash
$ DOTENV_CONFIG_ENCODING=latin1 node -r dotenv-expand/config your_script.js dotenv_config_path=/custom/path/to/.env
```

## Who's using dotenv-expand?

[These npm modules depend on it.](https://www.npmjs.com/browse/depended/dotenv-expand)
18 changes: 9 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dotenv-expand",
"version": "7.0.0",
"version": "8.0.0",
"description": "Expand environment variables using dotenv",
"main": "lib/main.js",
"types": "lib/main.d.ts",
Expand Down Expand Up @@ -36,7 +36,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",
Expand Down

0 comments on commit cc198df

Please sign in to comment.