build(broccoli): store DiffResult for re-use only if DiffResult
One of the non-angular broccoli plugins returns a weird object. We can't assume that all trees meet the contract that we expect them to meet, so we do a typecheck before storing the result of the rebuild. Closes #2662
This commit is contained in:
parent
9a290f0c22
commit
a93ec73e72
@ -74,12 +74,12 @@ class DiffingPluginWrapper implements BroccoliTree {
|
||||
// Otherwise, `this.diffResult` was produced from the output of the
|
||||
// inputTree's rebuild() method, and can be used without being checked.
|
||||
// Set `this.diffResult` to null and return the previously stored value.
|
||||
if (!tree.diffResult) {
|
||||
let differ = index === false ? this.treeDiffer : this.treeDiffers[index];
|
||||
return differ.diffTree();
|
||||
}
|
||||
let diffResult = tree.diffResult;
|
||||
tree.diffResult = null;
|
||||
if (!diffResult) {
|
||||
let differ = index === false ? this.treeDiffer : this.treeDiffers[index];
|
||||
diffResult = differ.diffTree();
|
||||
}
|
||||
return diffResult;
|
||||
};
|
||||
|
||||
@ -93,10 +93,11 @@ class DiffingPluginWrapper implements BroccoliTree {
|
||||
}
|
||||
|
||||
private maybeStoreDiffResult(value: (DiffResult | void)) {
|
||||
this.diffResult = value ? <DiffResult>(value) : null;
|
||||
if (!(value instanceof DiffResult)) value = null;
|
||||
this.diffResult = <DiffResult>(value);
|
||||
}
|
||||
|
||||
rebuild() {
|
||||
rebuild(): (Promise<any>| void) {
|
||||
try {
|
||||
let firstRun = !this.initialized;
|
||||
this.init();
|
||||
|
Loading…
x
Reference in New Issue
Block a user