Comparing version 0.2.0 to 0.3.0
0.3.0 / 2015-10-24 | ||
================== | ||
* added: `tree.getEntries([from])` which filters out entries unreachable from the given `from` file | ||
0.2.0 / 2015-10-22 | ||
@@ -3,0 +8,0 @@ ================== |
@@ -40,8 +40,17 @@ | ||
getEntries() { | ||
getEntries(from) { | ||
debug('listing entry files'); | ||
return Array.from(this.graph.sinks()).map(function (vertex) { | ||
debug('found source %s', vertex[0]); | ||
let entries = Array.from(this.graph.sinks()).map(function (vertex) { | ||
return vertex[0]; | ||
}); | ||
if (from) { | ||
debug('filtering out entry files not linked to %s', from); | ||
entries = entries.filter(function (entry) { | ||
return from === entry || this.graph.hasPath(from, entry); | ||
}, this); | ||
} | ||
debug('%s entries found %j', entries.length, entries); | ||
return entries; | ||
} | ||
@@ -48,0 +57,0 @@ |
{ | ||
"name": "mako-tree", | ||
"version": "0.2.0", | ||
"version": "0.3.0", | ||
"description": "The build tree structure used internally by mako", | ||
@@ -5,0 +5,0 @@ "repository": "makojs/tree", |
@@ -69,3 +69,3 @@ # mako-tree | ||
### Tree#getEntries() | ||
### Tree#getEntries([from]) | ||
@@ -75,2 +75,5 @@ Returns an `Array` of all the entry files in this graph. (in other words, files that are at the | ||
If `from` is provided, the returned list will only include entries that are reachable from that | ||
specified file. | ||
### Tree#hasDependency(parent, child) | ||
@@ -136,5 +139,4 @@ | ||
When initialized, it will simply reflect the extension of `File#path`. However, some plugins may | ||
need to modify this value if they end up changing how it should be interpreted. For example, a | ||
CoffeeScript plugin would switch from `"coffee"` to `"js"`. | ||
**NOTE:** plugins can modify this value if their work changes the file type. (such as compiling | ||
`.coffee` into `.js`) | ||
@@ -146,2 +148,10 @@ ### File#contents | ||
**NOTE:** must be set by a plugin. | ||
### File#output | ||
The absolute path to where this file should be written on disk. | ||
**NOTE:** must be set by a plugin. | ||
### File#isEntry() | ||
@@ -148,0 +158,0 @@ |
@@ -85,3 +85,3 @@ | ||
describe('#getEntries()', function () { | ||
describe('#getEntries([from])', function () { | ||
it('should return an empty list', function () { | ||
@@ -122,2 +122,20 @@ let tree = new Tree(); | ||
}); | ||
context('with from', function () { | ||
it('should only return all the linked entries', function () { | ||
// a <- b | ||
// c <- d <- e | ||
let tree = new Tree(); | ||
tree.addFile('a'); | ||
tree.addFile('b'); | ||
tree.addFile('c'); | ||
tree.addFile('d'); | ||
tree.addFile('e'); | ||
tree.addDependency('a', 'b'); | ||
tree.addDependency('c', 'd'); | ||
tree.addDependency('d', 'e'); | ||
assert.deepEqual(tree.getEntries('e'), [ 'c' ]); | ||
}); | ||
}); | ||
}); | ||
@@ -124,0 +142,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
26789
508
176