Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
broccoli-merge-trees
Advanced tools
The broccoli-merge-trees npm package is used to merge multiple Broccoli trees into a single tree. This is useful in build processes where you need to combine outputs from different sources or plugins into one cohesive output.
Basic Merge
This feature allows you to merge two or more trees into a single tree. The code sample demonstrates merging two trees located at 'path/to/tree1' and 'path/to/tree2'.
const mergeTrees = require('broccoli-merge-trees');
const tree1 = 'path/to/tree1';
const tree2 = 'path/to/tree2';
const mergedTree = mergeTrees([tree1, tree2]);
Overwrite Option
This feature allows you to specify whether files in later trees should overwrite files in earlier trees. The code sample demonstrates merging two trees with the overwrite option set to true.
const mergeTrees = require('broccoli-merge-trees');
const tree1 = 'path/to/tree1';
const tree2 = 'path/to/tree2';
const mergedTree = mergeTrees([tree1, tree2], { overwrite: true });
Annotation
This feature allows you to add an annotation to the merged tree for easier debugging and logging. The code sample demonstrates merging two trees with an annotation 'Merged Trees'.
const mergeTrees = require('broccoli-merge-trees');
const tree1 = 'path/to/tree1';
const tree2 = 'path/to/tree2';
const mergedTree = mergeTrees([tree1, tree2], { annotation: 'Merged Trees' });
The broccoli-concat package is used to concatenate multiple files into a single file. While broccoli-merge-trees combines entire trees, broccoli-concat focuses on combining file contents. This can be useful for tasks like combining JavaScript or CSS files.
The broccoli-funnel package allows you to filter and move files within a tree. It provides more granular control over the contents of a tree compared to broccoli-merge-trees, which merges entire trees. This can be useful for tasks like copying specific files or directories.
The broccoli-stew package offers a collection of Broccoli plugins for various tasks, including file manipulation, logging, and debugging. It provides more specialized functionalities compared to the general tree merging capabilities of broccoli-merge-trees.
Copy multiple trees of files on top of each other, resulting in a single merged tree.
npm install --save-dev broccoli-merge-trees
function call
const broccoliMergeTrees = require('broccoli-merge-trees');
let mergedNode = broccoliMergeTrees(inputNodes, options);
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
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.
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
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.
FAQs
Broccoli plugin to merge multiple trees into one
We found that broccoli-merge-trees demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.