Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

broccoli-merge-trees

broccolijs2mMIT4.2.0TypeScript support: definitely-typed

Broccoli plugin to merge multiple trees into one

broccoli-plugin, merge, copy

readme

broccoli-merge-trees

CI

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

Installation

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:

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:

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.

changelog

master

4.2.0

  • Use new public location for volta-cli/action
  • switch to GH actions
  • bump all dependencies

4.1.0

  • [Enhancement] add destDir

4.0.0

  • [Breaking] Require Node 10 or >= 12
  • Use Class Syntax
  • Upgrade dependencies

3.0.0

  • Upgrade to node-merge-trees ^2.0.0; this reduces code complexity and fixes an obscure bug

  • Bump minimum Node version to 6.0.0

2.0.0

  • Require Node >= 4

1.2.4

  • Revert to version 1.2.1 to restore Node 0.10 compatibility

1.2.3

  • Bump merge-trees dependency for Node 4 compatibility

1.2.2

  • Extract logic into node-merge-trees package

1.2.1

  • Fix typo with cache directory opt-out.

1.2.0

  • Opt out of cache directory creation.

1.1.4

  • Use heimdalljs for instrumentation and logging

1.1.3

  • Include only necessary files in npm package

1.1.2

  • Update fs-tree-diff, fixes "rename only file in directory" bug, and possible performance improvements.

1.1.1

  • Upgrade to can-symlink 1.0.0

1.1.0

  • Update output directory incrementally for better performance

1.0.0

  • Version bump without change

0.2.4

  • Clearer error messages

0.2.3

  • Add debug logging

0.2.2

  • Use broccoli-plugin base class, and add annotation option

0.2.1

  • Use node-symlink-or-copy to enable possible future symlink support on Windows

0.2.0

0.1.4

  • Make file overwriting case insensitive (on all platforms)

0.1.3

  • Copy instead of hardlinking

0.1.2

  • Update dependencies

0.1.1

  • Use new broccoli-writer base class

0.1.0

  • Initial version, extracted from broccoli.MergedTree