UNPKG

2.19 kBMarkdownView Raw
1# broccoli-merge-trees
2
3[![Build Status](https://travis-ci.org/broccolijs/broccoli-merge-trees.svg?branch=master)](https://travis-ci.org/broccolijs/broccoli-merge-trees)
4[![Build status](https://ci.appveyor.com/api/projects/status/9fkvegf4qbvfsg5v?svg=true)](https://ci.appveyor.com/project/embercli/broccoli-merge-trees)
5
6Copy multiple trees of files on top of each other, resulting in a single merged tree.
7
8## Installation
9
10```bash
11npm install --save-dev broccoli-merge-trees
12```
13
14## Usage
15
16* As a `function call`
17```js
18const broccoliMergeTrees = require('broccoli-merge-trees');
19
20let mergedNode = broccoliMergeTrees(inputNodes, options);
21```
22
23* With `new`
24```js
25const { MergeTrees } = require('broccoli-merge-trees');
26
27let mergedNode = new MergeTrees(inputNodes, options);
28```
29
30* **`inputNodes`**: An array of nodes, whose contents will be merged
31
32* **`options`**: A hash of options
33
34### Options
35
36* `overwrite`: By default, broccoli-merge-trees throws an error when a file
37 exists in multiple nodes. If you pass `{ overwrite: true }`, the output
38 will contain the version of the file as it exists in the last input
39 node that contains it.
40
41* `annotation`: A note to help tell multiple plugin instances apart.
42
43### Example
44
45If this is your `Brocfile.js`:
46
47```js
48const mergeTrees = require('broccoli-merge-trees');
49
50module.exports = function() {
51 return mergeTrees(['public','scripts']);
52};
53```
54
55And your project contains these files:
56
57 .
58 ├─ public
59 │ ├─ index.html
60 │ └─ images
61 │ └─ logo.png
62 ├─ scripts
63 │ └─ app.js
64 ├─ Brocfile.js
65
66
67Then running `broccoli build the-output` will generate this folder:
68
69 the-output
70 ├─ app.js
71 ├─ index.html
72 └─ images
73 └─ logo.png
74
75The 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.
76
77## Contributing
78
79Clone this repo and run the tests like so:
80
81```
82npm install
83npm test
84```
85
86Issues and pull requests are welcome. If you change code, be sure to re-run
87`npm test`. Oftentimes it's useful to add or update tests as well.