Skip to content

Commit

Permalink
Revert "unneded logic"
Browse files Browse the repository at this point in the history
This reverts commit 18a9c8e.
  • Loading branch information
motdotla committed Nov 18, 2024
1 parent 18a9c8e commit 6af96d4
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@ function expandValue (value, processEnv, runningParsed) {

let result = value
let match
const seen = new Set() // self-referential checker

while ((match = regex.exec(result)) !== null) {
seen.add(result)

const [template, bracedExpression, unbracedExpression] = match
const expression = bracedExpression || unbracedExpression

Expand All @@ -38,12 +41,17 @@ function expandValue (value, processEnv, runningParsed) {
}

if (value) {
result = result.replace(template, value)
// self-referential check
if (seen.has(value)) {
result = result.replace(template, defaultValue)
} else {
result = result.replace(template, value)
}
} else {
result = result.replace(template, defaultValue)
}

// if the result equaled what was in runningParsed then stop expanding - handle self-referential check as well
// if the result equaled what was in process.env and runningParsed then stop expanding
if (result === runningParsed[key]) {
break
}
Expand Down

0 comments on commit 6af96d4

Please sign in to comment.