1 | 'use strict';
|
2 |
|
3 | var Plugin = require('broccoli-plugin');
|
4 | var MergeTrees = require('merge-trees');
|
5 |
|
6 | module.exports = BroccoliMergeTrees;
|
7 | BroccoliMergeTrees.prototype = Object.create(Plugin.prototype);
|
8 | BroccoliMergeTrees.prototype.constructor = BroccoliMergeTrees;
|
9 | function BroccoliMergeTrees(inputNodes, options) {
|
10 | if (!(this instanceof BroccoliMergeTrees)) return new BroccoliMergeTrees(inputNodes, options);
|
11 | options = options || {};
|
12 | var name = 'broccoli-merge-trees:' + (options.annotation || '');
|
13 | if (!Array.isArray(inputNodes)) {
|
14 | throw new TypeError(name + ': Expected array, got: [' + inputNodes +']');
|
15 | }
|
16 | Plugin.call(this, inputNodes, {
|
17 | persistentOutput: true,
|
18 | needsCache: false,
|
19 | annotation: options.annotation
|
20 | });
|
21 | this.options = options;
|
22 | }
|
23 |
|
24 | BroccoliMergeTrees.prototype.build = function() {
|
25 | if (this.mergeTrees == null) {
|
26 |
|
27 |
|
28 | this.mergeTrees = new MergeTrees(this.inputPaths, this.outputPath, {
|
29 | overwrite: this.options.overwrite,
|
30 | annotation: this.options.annotation
|
31 | });
|
32 | }
|
33 |
|
34 | this.mergeTrees.merge();
|
35 | };
|