UNPKG

1.19 kBJavaScriptView Raw
1'use strict';
2
3var Plugin = require('broccoli-plugin');
4var MergeTrees = require('merge-trees');
5
6module.exports = BroccoliMergeTrees;
7BroccoliMergeTrees.prototype = Object.create(Plugin.prototype);
8BroccoliMergeTrees.prototype.constructor = BroccoliMergeTrees;
9function 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
24BroccoliMergeTrees.prototype.build = function() {
25 if (this.mergeTrees == null) {
26 // Defer instantiation until the first build because we only
27 // have this.inputPaths and this.outputPath once we build.
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};