mirror of
https://github.com/TECHNOFAB11/ergogen.git
synced 2025-12-12 16:10:04 +01:00
Prevent circular dependencies in $extends
This commit is contained in:
parent
dd6ff93a89
commit
887220abe3
6 changed files with 17 additions and 4 deletions
|
|
@ -69,11 +69,12 @@ exports.inherit = config => traverse(config, config, [], (target, key, val, root
|
|||
const list = [val]
|
||||
while (candidates.length) {
|
||||
const path = candidates.shift()
|
||||
const other = u.deepcopy(u.deep(root, path))
|
||||
const other = u.deep(root, path)
|
||||
a.assert(other, `"${path}" (reached from "${breadcrumbs.join('.')}.$extends") does not name a valid inheritance target!`)
|
||||
let parents = other.$extends || []
|
||||
if (a.type(parents)() !== 'array') parents = [parents]
|
||||
candidates = candidates.concat(parents)
|
||||
a.assert(!list.includes(other), `"${path}" (reached from "${breadcrumbs.join('.')}.$extends") leads to a circular dependency!`)
|
||||
list.unshift(other)
|
||||
}
|
||||
val = extend.apply(null, list)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue