forked from Addepar/ember-table
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBrocfile.js
47 lines (41 loc) · 1.08 KB
/
Brocfile.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
43
44
45
46
47
/* global require, module */
var EmberAddon = require('ember-cli/lib/broccoli/ember-addon');
var fs = require('fs');
// Escape HTML using approach in
// http://stackoverflow.com/questions/24816/escaping-html-strings-with-jquery
var entityMap = {
"&": "&",
"<": "<",
">": ">",
'"': '"',
"'": ''',
"/": '/'
};
function escapeHtml(string) {
return String(string).replace(/[&<>"'\/]/g, function (s) {
return entityMap[s];
});
}
var app = new EmberAddon({
/*
* Replace patterns. We use this to replace strings such as:
* @@{controllers/file.js}
* With the content of those files.
*/
replace: {
files: [
'**/*.js'
],
patterns: [{
match: /@@{([^}]*)}/g,
replacement: function(matchedText) {
filename = matchedText.slice(3, -1);
fullFilename = './tests/dummy/app/' + filename;
fileContents = fs.readFileSync(fullFilename, 'utf8');
return escapeHtml(fileContents).replace(/\n/g, '\\n');
}
}]
}
});
app.import(app.bowerDirectory + '/d3/d3.js');
module.exports = app.toTree();