diff --git a/lib/arch.js b/lib/arch.js index 88747c7..7b0dd1b 100644 --- a/lib/arch.js +++ b/lib/arch.js @@ -250,14 +250,16 @@ module.exports = INHERIT({ for (var i = 0; i < parents.length; i++) { parent = parents[i]; - children = this.children[parent] || (this.children[parent] = []); + if (!this.hasParents(child, parent)) { + children = this.children[parent] || (this.children[parent] = []); - if (_parents.indexOf(parent) === -1) _parents.push(parent); - if (children.indexOf(child) === -1) children.push(child); + if (_parents.indexOf(parent) === -1) _parents.push(parent); + if (children.indexOf(child) === -1) children.push(child); - for (var k in this.plans) { - var p = this.plans[k]; - if (p.hasNode(child) || p.hasNode(parent)) p.link(child, parent); + for (var k in this.plans) { + var p = this.plans[k]; + if (p.hasNode(child) || p.hasNode(parent)) p.link(child, parent); + } } } }, diff --git a/test/arch-test.js b/test/arch-test.js index ba6a32f..51e4816 100644 --- a/test/arch-test.js +++ b/test/arch-test.js @@ -139,6 +139,7 @@ suite arch.setNode('A', { run: 'testA' }); arch.setNode('B', { run: 'testA' }); arch.link('B', 'A'); + arch.link('B', 'A'); return arch; }, @@ -162,6 +163,7 @@ suite arch.setNode('A', { run: 'testA' }); arch.setNode('B', { run: 'testB' }, 'A'); arch.unlink('B', 'A'); + arch.unlink('B', 'A'); return arch; },