Created
December 1, 2015 18:56
-
-
Save timmfin/bb03df7d138827132f0c to your computer and use it in GitHub Desktop.
Revisions
-
timmfin created this gist
Dec 1, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,25 @@ function beforeBuild(node, cb, options) { // Get the last "child node" from our passed node's array of "children" inputNodes // (see https://github.com/broccolijs/broccoli-plugin/blob/master/index.js for // more context) var lastChildNode = node._inputNodes.pop(); // Take that child node and wrap it with our own, new plugin. Using // timmfin/broccoli-quick-plugin as a shortcut we don't have to create a new // contructor with all the broilerplate to extend broccoli-plugin inline. var wrappedChildNode = QuickPlugin([lastChildNode], { build: function() { cb(); }, name: "beforeBuild", annotation: (options || {}).annotation }); // Next we add our wrapped child node back to the end of the "children" list node._inputNodes.push(wrappedChildNode); // Lastly return the modified node. When the builder builds its sorted array // of the whole build graph, we will now have a "hook" that is run before the // build method of the original node passed to this function. return node; };