Skip to content

Commit eb7ad1d

Browse files
committed
demonstrate reverse expansion for now
1 parent 266dbfc commit eb7ad1d

File tree

3 files changed

+20
-4
lines changed

3 files changed

+20
-4
lines changed

CHANGELOG.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,6 @@ All notable changes to this project will be documented in this file. See [standa
2020

2121
> This has always been dangerous (unexpected side effects) and is now removed. `process.env` should not hold values you want to expand. If for some reason you need equivalent abilities, use [dotenvx](https://github.com/dotenvx/dotenvx). You can ship an encrypted .env file with your code - allowing safe expansion at runtime - rather than relying on trying to expand pre-existing `process.env` values that could for good reason have a dollar sign in them (example a password).
2222
23-
* ⚠️ BREAKING: do NOT expand in reverse order ([#131](https://github.com/motdotla/dotenv-expand/pull/131))
24-
25-
> Instead, order your KEYS from first to last as they depend on each other for expansion - principle of least surprise.
26-
2723
## [11.0.7](https://github.com/motdotla/dotenv-expand/compare/v11.0.6...v11.0.7) (2024-11-13)
2824

2925
### Changed

tests/.env.test

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,3 +82,9 @@ PASSWORD_EXPAND_NESTED_NESTED=${PASSWORD_EXPAND_NESTED}
8282

8383
USE_IF_SET=true
8484
ALTERNATE=${USE_IF_SET:+alternate}
85+
86+
# https://github.com/motdotla/dotenv-expand/issues/123
87+
FIRST_PAGE_URL=${PROJECT_PUBLIC_HOST}/first-page
88+
MOCK_SERVER_HOST=http://localhost:${MOCK_SERVER_PORT}
89+
MOCK_SERVER_PORT=8090
90+
PROJECT_PUBLIC_HOST=${MOCK_SERVER_HOST}

tests/main.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -598,3 +598,17 @@ t.test('expands alternate logic when not set', ct => {
598598

599599
ct.end()
600600
})
601+
602+
// WARNING: this is a side effect of dotenv.config prior loading to process.env. THIS IS NOT ACCURATE behavior and is removed in [dotenvx](https://github.com/dotenvx/dotenvx) to match bash expectations.
603+
// DO NOT RELY ON this, instead order your KEYS appropriately
604+
t.test('expansion for https://github.com/motdotla/dotenv-expand/issues/123', ct => {
605+
const dotenv = require('dotenv').config({ path: 'tests/.env.test' })
606+
dotenvExpand.expand(dotenv)
607+
608+
ct.equal(process.env.FIRST_PAGE_URL, 'http://localhost:8090/first-page')
609+
ct.equal(process.env.MOCK_SERVER_HOST, 'http://localhost:8090')
610+
ct.equal(process.env.MOCK_SERVER_PORT, '8090')
611+
ct.equal(process.env.PROJECT_PUBLIC_HOST, 'http://localhost:8090')
612+
613+
ct.end()
614+
})

0 commit comments

Comments
 (0)