forked from rwjblue/broccoli-export-tree
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
32 lines (25 loc) · 909 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
var fs = require('fs');
var path = require('path');
var rimraf = require('rimraf');
var Writer = require('broccoli-writer');
var helpers = require('broccoli-kitchen-sink-helpers')
ExportTree.prototype = Object.create(Writer.prototype);
ExportTree.prototype.constructor = ExportTree;
function ExportTree (inputTree, options) {
if (!(this instanceof ExportTree)) return new ExportTree(inputTree, options);
this.inputTree = inputTree;
this.destDir = options.destDir;
this.clobber = true;
if (options.hasOwnProperty('clobber')) { this.clobber = options.clobber; }
};
ExportTree.prototype.write = function (readTree, destDir) {
var self = this
return readTree(this.inputTree).then(function (srcDir) {
if (self.clobber) {
console.log('clobbering');
rimraf.sync(self.destDir);
}
helpers.copyRecursivelySync(srcDir, self.destDir);
})
};
module.exports = ExportTree;