-
Notifications
You must be signed in to change notification settings - Fork 36
/
index.js
38 lines (28 loc) · 926 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
33
34
35
36
37
38
'use strict';
const writeFile = require('broccoli-file-creator');
const mergeTrees = require('broccoli-merge-trees');
const { dasherize } = require('ember-cli-string-utils');
function addMath(trees) {
let index = '';
Object.getOwnPropertyNames(Math).forEach(key => {
let func = Math[key];
if (typeof func === 'function' && func.length) {
let dasherized = dasherize(key);
index += `export { default as ${key} } from './${dasherized}';`;
trees.push(writeFile(`math/${dasherized}.js`, `
import { curriedComputed } from 'ember-macro-helpers';
export default curriedComputed(Math.${key});
`));
}
});
trees.push(writeFile('math/index.js', index));
}
module.exports = {
name: require('./package').name,
treeForAddon(tree) {
let trees = [tree];
addMath(trees);
tree = mergeTrees(trees);
return this._super.treeForAddon.call(this, tree);
}
};