Socket
Socket
Sign inDemoInstall

broccoli-merge-files

Package Overview
Dependencies
106
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    broccoli-merge-files

Broccoli plugin to merge multiple files into one or multiple files


Version published
Weekly downloads
46K
decreased by-10.33%
Maintainers
1
Install size
3.58 MB
Created
Weekly downloads
 

Readme

Source

broccoli-merge-files

Build Status npm version Download Total Node.js Versions code style: prettier dependencies devDependencies

Merge multiple trees of files into one or multiple files with a user-provided merge function.

Installation

yarn add -D broccoli-merge-files

Usage

const { BroccoliMergeFiles } = require('broccoli-merge-files');

const mergedNode = new BroccoliMergeFiles(inputNodes, {
  merge: entries => JSON.stringify(Object.fromEntries(entries))
});
  • inputNodes: An array of nodes, whose contents will be merged
  • options: A hash of options

Options

  • outputFileName?: string: Optional output file name, if merge returns just the file singular file contents.
  • async merge(files: [fileName, contents][]): Called with an array of all files to be merged.
    • If outputFileName is set, expected to return a string or Buffer.
    • If it is not set, expected to return an array or output files, like: [fileName, contents][], where fileName is a string and contents is a string or Buffer.
  • sort:
    • true (default): Sort in order of input nodes and then relative file path.
    • false: Skip any sorting. Must not be used in conjunction with DuplicateStrategy.KeepFirst or DuplicateStrategy.KeepLast.
    • (a: Entry, b: Entry) => number: Compare function that gets passed two entries. Basically what you would pass to [].sort().
  • duplicates: If multiple input nodes contain a file with the same relative file path...
    • 'prohibit' (default): an error will be thrown and the pipeline crashes.
    • 'keep-first': the file from the first input node containing it is kept.
    • 'keep-last': the file from the last input node containing it is kept.
    • 'keep-all': all files will be passed through to merge.
  • async transformFile?(path: string, contents: string | Buffer): any (optional): Lets you transform every file before passing it to merge.
  • patterns?: string | string[]: Glob patterns for fast-glob.
  • globOptions?: object: Glob options for fast-glob.
  • encoding?: string = 'utf8': The encoding to use when reading and writing files.
  • annotation?: string: A note to help tell multiple plugin instances apart.
  • broccoli-merge-trees — Copies multiple trees of files on top of each other, resulting in a single merged tree. Does not merge any individual files.

  • broccoli-flatiron — Takes in a single input tree and merges all input files into a single JS module. Since this plugin is deprecated and not maintained any more, broccoli-merge-files includes a compatibility util to do the same thing:

    const { BroccoliMergeFiles } = require('broccoli-merge-files');
    const flatiron = require('broccoli-merge-files/flatiron');
    
    new BroccoliMergeFiles([inputNode], {
      merge: files =>
        flatiron(files, {
          // trimExtensions: false,
          // prefix: 'export default ',
          // suffix: ';'
        }),
      outputFileName: 'files.js'
    });
    

Keywords

FAQs

Last updated on 18 Feb 2019

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc