Inspect Broccoli nodes; thin wrapper around node.__broccoliGetInfo__()
npm install broccoli-node-infoThis is a low-level package used to communicate with Broccoli nodes (that is,
plugin instances). It provides a thin wrapper aroundnode.__broccoliGetInfo__(), normalizing different versions of the node API
to the newest version.
This package is mainly used by the Broccoli Builder class, but it can also
be used for inspecting nodes for testing, wrapping, diagnostics, or similar
purposes. If you are tempted to call node.__broccoliGetInfo__() or access
private variables on
broccoli-plugin instances,
such as node._name or node._inputNodes, then use this package instead!
For background on the Broccoli node API, see
docs/node-api.md.
``js
var broccoliNodeInfo = require('broccoli-node-info');
node = new SomeBroccoliPlugin();
var nodeInfo = broccoliNodeInfo.getNodeInfo(node);
// Now we can use nodeInfo.name, nodeInfo.annotation, etc.
`
This function calls node.__broccoliGetInfo__(broccoliNodeInfo.features).
For node objects conforming to the most recent node API, it simply returnsnodeInfo
the resulting object.
For node object conforming to an older version of the node API, it providesnodeInfo
compatibility code to normalize the object.
As a result, regardless of the API version used by the node object, wenodeInfo
obtain a object conforming to the current specification in
docs/node-api.md
This function throws a broccoliNodeInfo.InvalidNodeError when called with
* a plain string node (while still supported by the Broccoli Builder, they.read/.rebuild
are deprecated in favor of
broccoli-source),
* a node using the old API (see
docs/broccoli-1-0-plugin-api.md), or
* some other object that isn't a node.
Error subclass, potentially thrown by getNodeInfo().
A hash of all supported feature flags. This hash acts like a version number
for the node API. In the current version, its value is
`js``
{
persistentOutputFlag: true,
sourceDirectories: true
}