Skip to content

Commit

Permalink
add failing spec for recursive expansion beginning from pre-existing …
Browse files Browse the repository at this point in the history
…process.env
  • Loading branch information
motdotla committed Feb 17, 2024
1 parent 13a0555 commit 8fdcb93
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions tests/.env.test
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,5 @@ DOMAIN="https://${HOST}"

https://github.com/motdotla/dotenv-expand/issues/120
BASE_URL=https://${APP_DOMAIN}/api/
PUBLIC_DOMAIN="${DEVCONTAINER_CADDY_PUBLIC_DOMAIN}"
PUBLIC_BASE_URL="https://${PUBLIC_DOMAIN}"
12 changes: 12 additions & 0 deletions tests/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,18 @@ t.test('expands using processEnv already set on docker machine', ct => {
ct.end()
})

t.test('recursively expands using processEnv already set on docker machine', ct => {
process.env.DEVCONTAINER_CADDY_PUBLIC_DOMAIN = 'mydom.test' // simulate env set on docker already

const dotenv = require('dotenv').config({ path: 'tests/.env.test' })
dotenvExpand.expand(dotenv)

ct.equal(process.env.PUBLIC_DOMAIN, 'mydom.test')
ct.equal(process.env.PUBLIC_BASE_URL, 'https://mydom.test')

ct.end()
})

t.test('does not expand dollar sign that are not variables', ct => {
const dotenv = {
parsed: {
Expand Down

0 comments on commit 8fdcb93

Please sign in to comment.