Skip to content

Commit

Permalink
demonstrate expansion from prior process.env
Browse files Browse the repository at this point in the history
  • Loading branch information
motdotla committed Feb 17, 2024
1 parent 3f5116c commit 13a0555
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
3 changes: 3 additions & 0 deletions tests/.env.test
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,6 @@ EXPAND_SELF=$EXPAND_SELF
# https://github.com/motdotla/dotenv-expand/issues/112#issuecomment-1937330651
HOST="something"
DOMAIN="https://${HOST}"

https://github.com/motdotla/dotenv-expand/issues/120
BASE_URL=https://${APP_DOMAIN}/api/
11 changes: 11 additions & 0 deletions tests/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,17 @@ t.test('does not attempt to expand password if already existed in processEnv', c
ct.end()
})

t.test('expands using processEnv already set on docker machine', ct => {
process.env.APP_DOMAIN = 'example.com' // simulate env set on docker already

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

ct.equal(process.env.BASE_URL, 'https://example.com/api/')

ct.end()
})

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

0 comments on commit 13a0555

Please sign in to comment.