Comparing version 0.4.0 to 0.4.1
0.4.1 / 2015-10-29 | ||
================== | ||
* allowing prune to remove files not able to reach a specific list of entries | ||
0.4.0 / 2015-10-28 | ||
@@ -3,0 +8,0 @@ ================== |
@@ -111,5 +111,5 @@ | ||
prune() { | ||
prune(entries) { | ||
debug('pruning orphaned files'); | ||
let entries = this.getEntries(); | ||
if (!entries) entries = this.getEntries(); | ||
let files = this.topologicalOrder(); | ||
@@ -120,4 +120,5 @@ | ||
.filter(file => { | ||
if (this.isEntry(file)) return false; | ||
return !entries.some(entry => this.graph.hasPath(file, entry)); | ||
return !entries.some(entry => { | ||
return entry === file || this.graph.hasPath(file, entry); | ||
}); | ||
}) | ||
@@ -124,0 +125,0 @@ .forEach(file => this.graph.destroyVertex(file)); |
{ | ||
"name": "mako-tree", | ||
"version": "0.4.0", | ||
"version": "0.4.1", | ||
"description": "The build tree structure used internally by mako", | ||
@@ -5,0 +5,0 @@ "repository": "makojs/tree", |
@@ -97,11 +97,2 @@ # mako-tree | ||
### Tree#moveDependency(from, to, child) | ||
A helper for moving a dependency on `child` from one parent to another, which is more explicit than | ||
manually adding and removing the dependency links. (which must be done in the right order due to | ||
the automatic cleanup behavior of removing dependencies) | ||
An example use case: after inlining a tree of CSS files, the images/fonts/etc will need to be moved | ||
from being dependencies of the input files, to the single output file. | ||
### Tree#dependenciesOf(file, [recursive]) | ||
@@ -125,6 +116,22 @@ | ||
### File(location) *(constructor)* | ||
### Tree#clone() | ||
Each instance represents a file in the overall build. | ||
Returns a new `Tree` object that is an effective clone of the original. | ||
### Tree#prune([entries]) | ||
Removes any orphaned files from the graph. A file is considered orphaned if it has no path to any | ||
file marked as an entry. | ||
If `entries` is passed, (must be an `Array`) then any files that cannot reach _those_ files will | ||
be removed from the graph. (essentially overrides the internal list of entries) | ||
### File(location, tree, [entry]) *(constructor)* | ||
Each instance represents a file in the overall build. The `location` is an absolute path, `tree` | ||
is the tree that contains this particular file and `entry` flags a file as an entry. | ||
Entry files are uniquely handled, particularly when it comes to `Tree#prune()`. Any files that do | ||
not have a path to some entry file are considered orphaned, and will be pruned. | ||
### File#path | ||
@@ -140,3 +147,3 @@ | ||
**NOTE:** plugins can modify this value if their work changes the file type. (such as compiling | ||
`.coffee` into `.js`) | ||
`coffee` into `js`) | ||
@@ -156,2 +163,19 @@ ### File#contents | ||
### File#analyzing | ||
An internal flag that helps mako know when a particular file is currently being analyzed. (to | ||
prevent race conditions and duplicating efforts) There is currently no public use for this | ||
property. | ||
### File#analyzed | ||
A flag that helps mako know when a particular file has already been analyzed, so it doesn't | ||
continuously analyze the same file during subsequent builds. | ||
In a `prewrite` hook, setting this property to `false` is effectively marking this file as "dirty", | ||
causing mako to run all the analyze hooks again. | ||
For example, [mako-stat](http://github.com/makojs/stat) will turn this flag off whenever the | ||
modification time for a file has changed. | ||
### File#isEntry() | ||
@@ -158,0 +182,0 @@ |
@@ -351,3 +351,3 @@ | ||
describe('#prune()', function () { | ||
describe('#prune([entries])', function () { | ||
it('should only remove orphaned files', function () { | ||
@@ -423,3 +423,21 @@ // a* <- b | ||
}); | ||
context('with entries', function () { | ||
it('should prune anything that cannot reach the provided list of files', function () { | ||
// a* <- b | ||
// c* <- d | ||
let tree = new Tree(); | ||
tree.addFile('a', true); | ||
tree.addFile('b'); | ||
tree.addFile('c', true); | ||
tree.addFile('d'); | ||
tree.addDependency('a', 'b'); | ||
tree.addDependency('c', 'd'); | ||
tree.prune([ 'c' ]); | ||
assert.deepEqual(tree.topologicalOrder(), [ 'd', 'c' ]); | ||
}); | ||
}); | ||
}); | ||
}); |
Sorry, the diff of this file is not supported yet
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
32531
635
200