Skip to content

Commit 6af96d4

Browse files
committed
Revert "unneded logic"
This reverts commit 18a9c8e.
1 parent 18a9c8e commit 6af96d4

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

lib/main.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,11 @@ function expandValue (value, processEnv, runningParsed) {
1111

1212
let result = value
1313
let match
14+
const seen = new Set() // self-referential checker
1415

1516
while ((match = regex.exec(result)) !== null) {
17+
seen.add(result)
18+
1619
const [template, bracedExpression, unbracedExpression] = match
1720
const expression = bracedExpression || unbracedExpression
1821

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

4043
if (value) {
41-
result = result.replace(template, value)
44+
// self-referential check
45+
if (seen.has(value)) {
46+
result = result.replace(template, defaultValue)
47+
} else {
48+
result = result.replace(template, value)
49+
}
4250
} else {
4351
result = result.replace(template, defaultValue)
4452
}
4553

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

0 commit comments

Comments
 (0)