1. broccoli-merge-trees
Broccoli plugin to merge multiple trees into one
broccoli-merge-trees
Package: broccoli-merge-trees
Created by: broccolijs
Last modified: Mon, 13 Jun 2022 05:07:54 GMT
Version: 4.2.0
License: MIT
Downloads: 3,860,483
Repository: https://github.com/broccolijs/broccoli-merge-trees

Install

npm install broccoli-merge-trees
yarn add broccoli-merge-trees

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
 const broccoliMergeTrees = require('broccoli-merge-trees');

let mergedNode = broccoliMergeTrees(inputNodes, options);
  • With new
 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.

RELATED POST

10 Must-Know Windows Shortcuts That Will Save You Time

10 Must-Know Windows Shortcuts That Will Save You Time

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Navigating AWS Networking: Essential Hacks for Smooth Operation

Navigating AWS Networking: Essential Hacks for Smooth Operation

Achieving Stunning Visuals with Unity's Global Illumination

Achieving Stunning Visuals with Unity's Global Illumination

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code