Code Monkey home page Code Monkey logo

broccoli-merge-files's Introduction

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.

Related projects

  • 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-multifilter — A mix of broccoli-filter and broccoli-merge-files. If you can provide a declarative, static m-to-n file mapping up front, use this plugin instead, since it allows better caching.

  • 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'
    });

broccoli-merge-files's People

Contributors

buschtoens avatar dependabot-preview[bot] avatar dependabot-support avatar dependabot[bot] avatar

Watchers

 avatar  avatar  avatar

Forkers

ccdexcom

broccoli-merge-files's Issues

Package has a number of dependencies that contain CVEs

This package has dependencies on versions of packages that contain CVEs. This can be seen by the number of dependabot PR's that are present at the moment.

Output of running yarn audit on this repository (at commit 73a1afe):

370 vulnerabilities found - Packages audited: 755
Severity: 127 Moderate | 209 High | 34 Critical
Done in 1.58s.

Since this package is used by the popular ember-intl package, it makes that projects that use ember-intl get these CVEs too.

Is it possible to update the dependencies and release a new version?

TypeError: BroccoliMergeFiles is not a constructor

Here'a a screenshot of the simplest use case:
image

I can see in your index.ts that the default export is the class, but it looks like the compiled JS is missing a module.exports = BroccoliMergeFiles statement. Otherwise it requires node importers to do:

const BroccoliMergeFiles = require('broccoli-merge-files').default;

I don't know typescript super well, otherwise I'd open a PR.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.