8000 Merge pull request #875 from motdotla/quiet-true · motdotla/dotenv@a814691 · GitHub
[go: up one dir, main page]

Skip to content

Commit a814691

Browse files
authored
Merge pull request #875 from motdotla/quiet-true
`17.0.0` - `quiet: false` default
2 parents 076ba3b + e8978b0 commit a814691

File tree

5 files changed

+39
-10
lines changed

5 files changed

+39
-10
lines changed

CHANGELOG.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,13 @@
22

33
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.
44

5-
## [Unreleased](https://github.com/motdotla/dotenv/compare/v16.6.1...master)
5+
## [Unreleased](https://github.com/motdotla/dotenv/compare/v17.0.0...master)
6+
7+
## [17.0.0](https://github.com/motdotla/dotenv/compare/v16.6.1...v17.0.0) (2025-06-27)
8+
9+
### Changed
10+
11+
- Default `quiet` to false - runtime log message shows by default ([#875](https://github.com/motdotla/dotenv/pull/874))
612

713
## [16.6.1](https://github.com/motdotla/dotenv/compare/v16.6.0...v16.6.1) (2025-06-27)
814

README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,29 @@ Pass in multiple files as an array, and they will be parsed in order and combine
312312
require('dotenv').config({ path: ['.env.local', '.env'] })
313313
```
314314

315+
##### quiet
316+
317+
Default: `false`
318+
319+
Suppress runtime logging message.
320+
321+
```js
322+
// index.js
323+
require('dotenv').config({ quiet: false }) // change to true to suppress
324+
console.log(`Hello ${process.env.HELLO}`)
325+
```
326+
327+
```ini
328+
# .env
329+
.env
330+
```
331+
332+
```sh
333+
$ node index.js
334+
[dotenv@17.0.0] injecting env (1) from .env
335+
Hello World
336+
```
337+
315338
##### encoding
316339

317340
Default: `utf8`

lib/main.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ function _parseVault (options) {
9191
}
9292

9393
function _warn (message) {
94-
console.log(`[dotenv@${version}][WARN] ${message}`)
94+
console.error(`[dotenv@${version}][WARN] ${message}`)
9595
}
9696

9797
function _debug (message) {
@@ -190,7 +190,7 @@ function _resolveHome (envPath) {
190190

191191
function _configVault (options) {
192192
const debug = Boolean(options && options.debug)
193-
const quiet = options && 'quiet' in options ? options.quiet : true
193+
const quiet = Boolean(options && options.quiet)
194194

195195
if (debug || !quiet) {
196196
_log('Loading env from encrypted .env.vault')
@@ -212,7 +212,7 @@ function configDotenv (options) {
212212
const dotenvPath = path.resolve(process.cwd(), '.env')
213213
let encoding = 'utf8'
214214
const debug = Boolean(options && options.debug)
215-
const quiet = options && 'quiet' in options ? options.quiet : true
215+
const quiet = Boolean(options && options.quiet)
216216

217217
if (options && options.encoding) {
218218
encoding = options.encoding
@@ -274,7 +274,7 @@ function configDotenv (options) {
274274
}
275275
}
276276

277-
_log(`injecting env (${keysCount}) from ${shortPaths.join(',')}`)
277+
_log(`injecting env (${keysCount}) from ${shortPaths.join(',')} – 🔐 encrypt with dotenvx: https://dotenvx.com`)
278278
}
279279

280280
if (lastError) {

tests/test-config-vault.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ t.test('logs when no path is set', ct => {
3434
ct.ok(logStub.called)
3535
})
3636

37-
t.test('does not log by default', ct => {
37+
t.test('does log by default', ct => {
3838
ct.plan(1)
3939

4040
logStub = sinon.stub(console, 'log')
4141

4242
dotenv.config({ path: testPath })
43-
ct.ok(logStub.notCalled)
43+
ct.ok(logStub.called)
4444
})
4545

4646
t.test('does not log if quiet flag passed true', ct => {
@@ -79,13 +79,13 @@ t.test('logs if debug set', ct => {
7979
ct.ok(logStub.called)
8080
})
8181

82-
t.test('does not log when testPath calls to .env.vault directly (interpret what the user meant)', ct => {
82+
t.test('does log when testPath calls to .env.vault directly (interpret what the user meant)', ct => {
8383
ct.plan(1)
8484

8585
logStub = sinon.stub(console, 'log')
8686

8787
dotenv.config({ path: `${testPath}.vault` })
88-
ct.ok(logStub.notCalled)
88+
ct.ok(logStub.called)
8989
})
9090

9191
t.test('logs when testPath calls to .env.vault directly (interpret what the user meant) and debug true', ct => {

tests/test-config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ t.test('deals with file:// path', ct => {
261261
ct.equal(process.env.BASIC, undefined)
262262
ct.equal(env.error.message, "ENOENT: no such file or directory, open 'file:///tests/.env'")
263263

264-
ct.ok(logStub.notCalled)
264+
ct.ok(logStub.called)
265265

266266
logStub.restore()
267267

0 commit comments

Comments
 (0)
0