Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@

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/compare/v16.6.1...master)
## [Unreleased](https://github.com/motdotla/dotenv/compare/v17.0.0...master)

## [17.0.0](https://github.com/motdotla/dotenv/compare/v16.6.1...v17.0.0) (2025-06-27)

### Changed

- Default `quiet` to false - runtime log message shows by default ([#875](https://github.com/motdotla/dotenv/pull/874))

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

Expand Down
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,29 @@ Pass in multiple files as an array, and they will be parsed in order and combine
require('dotenv').config({ path: ['.env.local', '.env'] })
```

##### quiet

Default: `false`

Suppress runtime logging message.

```js
// index.js
require('dotenv').config({ quiet: false }) // change to true to suppress
console.log(`Hello ${process.env.HELLO}`)
```

```ini
# .env
.env
```

```sh
$ node index.js
[dotenv@17.0.0] injecting env (1) from .env
Hello World
```

##### encoding

Default: `utf8`
Expand Down
8 changes: 4 additions & 4 deletions lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ function _parseVault (options) {
}

function _warn (message) {
console.log(`[dotenv@${version}][WARN] ${message}`)
console.error(`[dotenv@${version}][WARN] ${message}`)
}

function _debug (message) {
Expand Down Expand Up @@ -190,7 +190,7 @@ function _resolveHome (envPath) {

function _configVault (options) {
const debug = Boolean(options && options.debug)
const quiet = options && 'quiet' in options ? options.quiet : true
const quiet = Boolean(options && options.quiet)

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

if (options && options.encoding) {
encoding = options.encoding
Expand Down Expand Up @@ -274,7 +274,7 @@ function configDotenv (options) {
}
}

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

if (lastError) {
Expand Down
8 changes: 4 additions & 4 deletions tests/test-config-vault.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ t.test('logs when no path is set', ct => {
ct.ok(logStub.called)
})

t.test('does not log by default', ct => {
t.test('does log by default', ct => {
ct.plan(1)

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

dotenv.config({ path: testPath })
ct.ok(logStub.notCalled)
ct.ok(logStub.called)
})

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

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

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

dotenv.config({ path: `${testPath}.vault` })
ct.ok(logStub.notCalled)
ct.ok(logStub.called)
})

t.test('logs when testPath calls to .env.vault directly (interpret what the user meant) and debug true', ct => {
Expand Down
2 changes: 1 addition & 1 deletion tests/test-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ t.test('deals with file:// path', ct => {
ct.equal(process.env.BASIC, undefined)
ct.equal(env.error.message, "ENOENT: no such file or directory, open 'file:///tests/.env'")

ct.ok(logStub.notCalled)
ct.ok(logStub.called)

logStub.restore()

Expand Down