Comparing version 0.10.1 to 0.11.0
0.11.0 / 2016-02-10 | ||
=================== | ||
* adding a method for removing cycles from a tree | ||
0.10.1 / 2016-02-09 | ||
@@ -3,0 +8,0 @@ =================== |
@@ -348,2 +348,10 @@ | ||
removeCycles() { | ||
debug('removing cycles from tree'); | ||
for (let cycle of this.graph.cycles()) { | ||
this.removeDependency(cycle[1], cycle[0]); | ||
} | ||
debug('done removing cycles from tree'); | ||
} | ||
/** | ||
@@ -350,0 +358,0 @@ * Returns a trimmed object that can be serialized as JSON. It includes a list |
{ | ||
"name": "mako-tree", | ||
"version": "0.10.1", | ||
"version": "0.11.0", | ||
"main": "./lib/tree", | ||
@@ -11,3 +11,3 @@ "description": "The build tree structure used internally by mako", | ||
"file-extension": "^2.0.1", | ||
"graph-toposort": "^0.1.1", | ||
"graph-toposort": "^0.2.0", | ||
"graph.js": "^1.20.1", | ||
@@ -14,0 +14,0 @@ "regex-iso-date": "^1.0.0" |
@@ -612,2 +612,57 @@ | ||
describe('#removeCycles()', function () { | ||
it('should remove shallow cycles', function () { | ||
// a <- b <- c* | ||
// <- c <- b* | ||
let tree = new Tree(); | ||
tree.addFile('a', true); | ||
tree.addFile('b'); | ||
tree.addFile('c'); | ||
tree.addDependency('a', 'b'); | ||
tree.addDependency('a', 'c'); | ||
tree.addDependency('b', 'c'); | ||
tree.addDependency('c', 'b'); | ||
tree.removeCycles(); | ||
assert.deepEqual(tree.getFiles({ topological: true }), [ 'c', 'b', 'a' ]); | ||
}); | ||
it('should remove cycles found deeper in the graph', function () { | ||
// a <- b <- c <- d* | ||
// <- d <- c* | ||
let tree = new Tree(); | ||
tree.addFile('a', true); | ||
tree.addFile('b'); | ||
tree.addFile('c'); | ||
tree.addFile('d'); | ||
tree.addDependency('a', 'b'); | ||
tree.addDependency('b', 'c'); | ||
tree.addDependency('b', 'd'); | ||
tree.addDependency('c', 'd'); | ||
tree.addDependency('d', 'c'); | ||
tree.removeCycles(); | ||
assert.deepEqual(tree.getFiles({ topological: true }), [ 'd', 'c', 'b', 'a' ]); | ||
}); | ||
it('should remove large cycles in the graph', function () { | ||
// a <- b <- c <- d <- b* | ||
let tree = new Tree(); | ||
tree.addFile('a', true); | ||
tree.addFile('b'); | ||
tree.addFile('c'); | ||
tree.addFile('d'); | ||
tree.addDependency('a', 'b'); | ||
tree.addDependency('b', 'c'); | ||
tree.addDependency('c', 'd'); | ||
tree.addDependency('d', 'b'); | ||
tree.removeCycles(); | ||
assert.deepEqual(tree.getFiles({ topological: true }), [ 'd', 'c', 'b', 'a' ]); | ||
}); | ||
}); | ||
describe('#toJSON()', function () { | ||
@@ -614,0 +669,0 @@ it('should return a list of vertices and edges for reconstructing the graph', function () { |
63564
1465
+ Addedgraph-toposort@0.2.0(transitive)
- Removedgraph-toposort@0.1.1(transitive)
Updatedgraph-toposort@^0.2.0