From a93ec73e726f92dbb42b36b5ee509b31a807a96f Mon Sep 17 00:00:00 2001 From: Caitlin Potter Date: Fri, 26 Jun 2015 06:35:41 -0500 Subject: [PATCH] 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 --- tools/broccoli/diffing-broccoli-plugin.ts | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/tools/broccoli/diffing-broccoli-plugin.ts b/tools/broccoli/diffing-broccoli-plugin.ts index 4548c1415c..6c9e3bf516 100644 --- a/tools/broccoli/diffing-broccoli-plugin.ts +++ b/tools/broccoli/diffing-broccoli-plugin.ts @@ -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 ? (value) : null; + if (!(value instanceof DiffResult)) value = null; + this.diffResult = (value); } - rebuild() { + rebuild(): (Promise| void) { try { let firstRun = !this.initialized; this.init();