# broccoli-merge-trees

> Broccoli plugin to merge multiple trees into one

Latest version **4.2.0** (published 2020-03-30) · MIT license · 0 weekly downloads

## Install

```sh
npm install broccoli-merge-trees
pnpm add broccoli-merge-trees
yarn add broccoli-merge-trees
bun add broccoli-merge-trees
```

## Health

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

Positive: has types package; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 4.2.0 |
| Published | 2020-03-30 |
| First published | 2014-04-05 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/broccoli-merge-trees) |
| Module format | CommonJS |
| Node | 10.* \|\| >= 12.* |
| Dependencies | 2 |
| Unpacked size | 7.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 27 |
| Author | Jo Liss |
| Maintainers | hjdivad, joliss, rwjblue, stefanpenner |
| Keywords | broccoli-plugin, merge, copy |

## Links

- npm: https://www.npmjs.com/package/broccoli-merge-trees
- Repository: https://github.com/broccolijs/broccoli-merge-trees
- Homepage: https://github.com/broccolijs/broccoli-merge-trees#readme
- Issues: https://github.com/broccolijs/broccoli-merge-trees/issues
- npm.io page: https://npm.io/package/broccoli-merge-trees

## Dependencies (2)

- [merge-trees](https://npm.io/package/merge-trees.md) ^2.0.0
- [broccoli-plugin](https://npm.io/package/broccoli-plugin.md) ^4.0.2

## Recent versions

- 4.2.0 (latest) — 2020-03-30
- 4.1.0 — 2019-12-19
- 4.0.0 — 2019-12-05
- 3.0.2 — 2018-11-29
- 2.0.1 — 2018-08-09
- 3.0.1 — 2018-08-09
- 3.0.0 — 2018-02-20
- 2.0.0 — 2017-03-06
- 1.2.4 — 2017-03-06
- 1.2.3 — 2017-03-02
- 1.2.2 — 2017-03-02
- 1.2.1 — 2016-12-02
- 1.2.0 — 2016-12-02
- 1.1.5 — 2016-11-17
- 1.1.4 — 2016-08-10
- … 12 more at https://npm.io/package/broccoli-merge-trees/versions

## README

# broccoli-merge-trees
![CI](https://github.com/broccolijs/broccoli-merge-trees/workflows/CI/badge.svg)

Copy multiple trees of files on top of each other, resulting in a single merged tree.

## Installation

```bash
npm install --save-dev broccoli-merge-trees
```

## Usage

* As a `function call`
```js
const broccoliMergeTrees = require('broccoli-merge-trees');

let mergedNode = broccoliMergeTrees(inputNodes, options);
```

* With `new`
```js
const { MergeTrees } = require('broccoli-merge-trees');

let mergedNode = new MergeTrees(inputNodes, options);
```

* **`inputNodes`**: An array of nodes, whose contents will be merged

* **`options`**: A hash of options

### Options

* `overwrite`: By default, broccoli-merge-trees throws an error when a file
  exists in multiple nodes. If you pass `{ overwrite: true }`, the output
  will contain the version of the file as it exists in the last input
  node that contains it.

* `annotation`: A note to help tell multiple plugin instances apart.

* `destDir`: A string representing the destination path that merged files will be copied to.

### Example

If this is your `Brocfile.js`:

```js
const mergeTrees = require('broccoli-merge-trees');

module.exports = function() {
  return mergeTrees(['public','scripts']);
};
```

And your project contains these files:

    .
    ├─ public
    │  ├─ index.html
    │  └─ images
    │     └─ logo.png
    ├─ scripts
    │  └─ app.js
    ├─ Brocfile.js
    …

Then running `broccoli build the-output` will generate this folder:

    the-output
    ├─ app.js
    ├─ index.html
    └─ images
       └─ logo.png

The parent folders, `public` and `scripts` in this case, are not included in the output. The output tree contains only the files *within* each folder, all mixed together.

------

If this is your `Brocfile.js`:

```js
var BroccoliMergeTrees = require('broccoli-merge-trees');

module.exports = new BroccoliMergeTrees(['public', 'scripts'], {
    destDir: 'assets'
});
```
Then running `broccoli build the-output` will generate this folder:

    the-output
    └─ assets
        ├─ app.js
        ├─ index.html
        └─ images
        └─ logo.png

## Contributing

Clone this repo and run the tests like so:

```
npm install
npm test
```

Issues and pull requests are welcome. If you change code, be sure to re-run
`npm test`. Oftentimes it's useful to add or update tests as well.

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