Skip to content

Commit

Permalink
Merge pull request #111 from motdotla/expand-same-variable
Browse files Browse the repository at this point in the history
demonstrate spec that recursive is fixed
  • Loading branch information
motdotla authored Feb 10, 2024
2 parents a2dad4c + 16249b6 commit 8102e2c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
3 changes: 3 additions & 0 deletions tests/.env.test
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,6 @@ DONT_CHOKE5='#la__nK?IxNlQ%`5q&DpcZ>Munx=[1-AMgAcwmPkToxTaB?kgdF5y`A8m=Oa-B!)'
DONT_CHOKE6='xlC&*<j4J<d._<JKH0RBJV!4(ZQEN-+&!0p137<g*hdY2H4xk?/;KO1\$(W{:Wc}Q'
DONT_CHOKE7='?\$6)m*xhTVewc#NVVgxX%eBhJjoHYzpXFg=gzn[rWXPLj5UWj@z\$/UDm8o79n/p%'
DONT_CHOKE8='@}:[4#g%[R-CFR});bY(Z[KcDQDsVn2_y4cSdU<Mjy!c^F`G<!Ks7]kbS]N1:bP:'

# https://github.com/motdotla/dotenv-expand/issues/98
EXPAND_SELF=$EXPAND_SELF
10 changes: 9 additions & 1 deletion tests/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
'use strict'

const t = require('tap')

const dotenvExpand = require('../lib/main')

t.test('returns object', ct => {
Expand Down Expand Up @@ -413,3 +412,12 @@ t.test('does not choke', ct => {

ct.end()
})

t.test('expands self without a recursive call stack error', ct => {
const dotenv = require('dotenv').config({ path: 'tests/.env.test', processEnv: {} })
const parsed = dotenvExpand.expand(dotenv).parsed

ct.equal(parsed.EXPAND_SELF, '$EXPAND_SELF') // because it ends up accessing parsed[key].

ct.end()
})

0 comments on commit 8102e2c

Please sign in to comment.