# broccoli-node-info

> Inspect Broccoli nodes; thin wrapper around node.__broccoliGetInfo__()

Latest version **2.2.0** (published 2021-05-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install broccoli-node-info
pnpm add broccoli-node-info
yarn add broccoli-node-info
bun add broccoli-node-info
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.2.0 |
| Published | 2021-05-25 |
| First published | 2016-07-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | 8.* \|\| >= 10.* |
| Dependencies | 0 |
| Unpacked size | 21.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Jo Liss |
| Maintainers | joliss, thoov, rwjblue, stefanpenner |
| Keywords | broccoli |

## Links

- npm: https://www.npmjs.com/package/broccoli-node-info
- Repository: https://github.com/broccolijs/broccoli-node-info
- Issues: https://github.com/broccolijs/broccoli-node-info/issues
- npm.io page: https://npm.io/package/broccoli-node-info

## Recent versions

- 2.2.0 (latest) — 2021-05-25
- 2.1.0 — 2019-08-15
- 2.0.0 — 2019-05-16
- 1.1.0 — 2016-12-02
- 1.0.0 — 2016-07-30

## README

# broccoli-node-info

This is a low-level package used to communicate with Broccoli nodes (that is,
plugin instances). It provides a thin wrapper around
`node.__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](https://github.com/broccolijs/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](https://github.com/broccolijs/broccoli/blob/master/docs/node-api.md).

## Usage

```js
var broccoliNodeInfo = require('broccoli-node-info');

node = new SomeBroccoliPlugin();

var nodeInfo = broccoliNodeInfo.getNodeInfo(node);
// Now we can use nodeInfo.name, nodeInfo.annotation, etc.
```

### `getNodeInfo(node)`

This function calls `node.__broccoliGetInfo__(broccoliNodeInfo.features)`.

For `node` objects conforming to the most recent node API, it simply returns
the resulting `nodeInfo` object.

For `node` object conforming to an older version of the node API, it provides
compatibility code to normalize the `nodeInfo` object.

As a result, regardless of the API version used by the `node` object, we
obtain a `nodeInfo` object conforming to the current specification in
[docs/node-api.md](https://github.com/broccolijs/broccoli/blob/master/docs/node-api.md#the-nodeinfo-object)

This function throws a `broccoliNodeInfo.InvalidNodeError` when called with

* a plain string node (while still supported by the Broccoli `Builder`, they
  are deprecated in favor of
  [broccoli-source](https://github.com/broccolijs/broccoli-source)),
* a node using the old `.read/.rebuild` API (see
  [docs/broccoli-1-0-plugin-api.md](https://github.com/broccolijs/broccoli/blob/master/docs/broccoli-1-0-plugin-api.md)), or
* some other object that isn't a node.

### `InvalidNodeError`

`Error` subclass, potentially thrown by `getNodeInfo()`.

### `features`

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
}
```

---
_Source: https://npm.io/package/broccoli-node-info · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
