You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: CHANGELOG.md
+23-1
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,29 @@
2
2
3
3
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.
`v15.0.0` is a major new release with some important breaking changes.
10
+
11
+
### Added
12
+
13
+
-_Breaking:_ Multiline parsing support (just works. no need for the flag.)
14
+
15
+
### Changed
16
+
17
+
-_Breaking:_`#` marks the beginning of a comment (UNLESS the value is wrapped in quotes. Please update your `.env` files to wrap in quotes any values containing `#`. For example: `SECRET_HASH="something-with-a-#-hash"`).
18
+
19
+
..Understandably, (as some teams have noted) this is tedious to do across the entire team. To make it less tedious, we recommend using [dotenv cli](https://github.com/dotenv-org/cli) going forward. It's an optional plugin that will keep your `.env` files in sync between machines, environments, or team members.
20
+
21
+
### Removed
22
+
23
+
-_Breaking:_ Remove multiline option (just works out of the box now. no need for the flag.)
24
+
25
+
### Changed
26
+
27
+
- Preserve backwards compatibility on values containing `#` 🐞 ([#603](https://github.com/motdotla/dotenv/pull/603))
Comments may be added to your file on their own line or inline:
83
+
84
+
```dosini
85
+
# This is a comment
86
+
SECRET_KEY=YOURSECRETKEYGOESHERE # comment
87
+
SECRET_HASH="something-with-a-#-hash"
88
+
```
89
+
90
+
Comments begin where a `#` exists, so if your value contains a `#` please wrap it in quotes. This is a breaking change from `>= v15.0.0` and on.
91
+
92
+
### Parsing
93
+
94
+
The engine which parses the contents of your file containing environment variables is available to use. It accepts a String or Buffer and will return an Object with the parsed keys and values.
95
+
96
+
```javascript
97
+
constdotenv=require('dotenv')
98
+
constbuf=Buffer.from('BASIC=basic')
99
+
constconfig=dotenv.parse(buf) // will return an object
You can use the `--require` (`-r`) [command line option](https://nodejs.org/api/cli.html#cli_r_require_module) to preload dotenv. By doing this, you do not need to require and load dotenv in your application code.
106
+
107
+
```bash
108
+
$ node -r dotenv/config your_script.js
109
+
```
110
+
111
+
The configuration options below are supported as command line arguments in the format `dotenv_config_<option>=value`
You need to add the value of another variable in one of your variables? Use [dotenv-expand](https://github.com/motdotla/dotenv-expand).
130
+
131
+
### Syncing
132
+
133
+
You need to keep `.env` files in sync between machines, environments, or team members? Use [dotenv cli](https://github.com/dotenv-org/cli).
134
+
79
135
## Examples
80
136
81
137
See [examples](https://github.com/dotenv-org/examples) of using dotenv with various frameworks, languages, and configurations.
@@ -163,27 +219,6 @@ Override any environment variables that have already been set on your machine wi
163
219
require('dotenv').config({ override:true })
164
220
```
165
221
166
-
##### Multiline
167
-
168
-
Default: `false`
169
-
170
-
Turn on multiline line break parsing.
171
-
172
-
```js
173
-
require('dotenv').config({ multiline:true })
174
-
```
175
-
176
-
This allows specifying multiline values in this format:
177
-
178
-
```
179
-
PRIVATE_KEY="-----BEGIN PRIVATE KEY-----
180
-
MIGT...
181
-
7ure...
182
-
-----END PRIVATE KEY-----"
183
-
```
184
-
185
-
Ensure that the value begins with a single or double quote character, and it ends with the same character.
186
-
187
222
### Parse
188
223
189
224
The engine which parses the contents of your file containing environment
// expect a debug message because the buffer is not in KEY=VAL form
214
249
```
215
250
216
-
##### Multiline
217
-
218
-
Default: `false`
219
-
220
-
Turn on multiline line break parsing.
221
-
222
-
```js
223
-
require('dotenv').config({ multiline:true })
224
-
```
225
-
226
-
This allows specifying multiline values in this format:
227
-
228
-
```
229
-
PRIVATE_KEY="-----BEGIN PRIVATE KEY-----
230
-
MIGT...
231
-
7ure...
232
-
-----END PRIVATE KEY-----"
233
-
```
234
-
235
251
## Other Usage
236
252
237
-
### Preload
238
-
239
-
You can use the `--require` (`-r`) [command line option](https://nodejs.org/api/cli.html#cli_r_require_module) to preload dotenv. By doing this, you do not need to require and load dotenv in your application code. This is the preferred approach when using `import` instead of `require`.
240
-
241
-
```bash
242
-
$ node -r dotenv/config your_script.js
243
-
```
244
-
245
-
The configuration options below are supported as command line arguments in the format `dotenv_config_<option>=value`
- whitespace is removed from both ends of unquoted values (see more on [`trim`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/Trim)) (`FOO= some value ` becomes `{FOO: 'some value'}`)
Does that make sense? It's a bit unintuitive, but it is how importing of ES6 modules work. Here is a [working example of this pitfall](https://github.com/dotenv-org/examples/tree/master/dotenv-es6-import-pitfall).
385
377
386
-
There are also 2 alternatives to this approach:
378
+
There are two alternatives to this approach:
387
379
388
380
1. Preload dotenv: `node --require dotenv/config index.js` (_Note: you do not need to `import` dotenv with this approach_)
389
381
2. Create a separate file that will execute `config` first as outlined in [this comment on #133](https://github.com/motdotla/dotenv/issues/133#issuecomment-255298822)
0 commit comments