-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
42 lines (33 loc) · 1.23 KB
/
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
33
34
35
36
37
38
39
40
41
42
'use strict';
var Filter = require('broccoli-filter');
var groundskeeper = require('groundskeeper');
var _escapeRegExp = function (string) {
return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
};
function GroundskeeperFilter (inputTree, options) {
if (!(this instanceof GroundskeeperFilter)) {
return new GroundskeeperFilter(inputTree, options);
}
this.inputTree = inputTree;
this.options = options || {};
}
GroundskeeperFilter.prototype = Object.create(Filter.prototype);
GroundskeeperFilter.prototype.constructor = GroundskeeperFilter;
GroundskeeperFilter.prototype.extensions = ['js'];
GroundskeeperFilter.prototype.targetExtension = 'js';
GroundskeeperFilter.prototype.canProcessFile = function (relativePath) {
if (this.getDestFilePath(relativePath) != null) {
var processFiles = this.options.processFiles || [];
return processFiles.length === 0 ||
processFiles.some(function (fileToProcess) {
return new RegExp(_escapeRegExp(fileToProcess) + '$').test(relativePath);
});
}
return false;
};
GroundskeeperFilter.prototype.processString = function (str) {
var cleaner = groundskeeper(this.options);
cleaner.write(str);
return cleaner.toString();
};
module.exports = GroundskeeperFilter;