forked from emberjs/ember-test-helpers
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ember-cli-build.js
113 lines (89 loc) · 2.91 KB
/
ember-cli-build.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
var Funnel = require('broccoli-funnel');
var mergeTrees = require('broccoli-merge-trees');
var Babel = require('broccoli-babel-transpiler');
var concat = require('broccoli-concat');
var eslint = require('broccoli-lint-eslint');
var existsSync = require('exists-sync');
module.exports = function(options) {
var project = options.project;
project.initializeAddons();
function eachAddonInvoke(method, args) {
return project.addons.map(function(addon) {
if (addon[method]) {
return addon[method].apply(addon, args);
}
});
}
function addonTreesFor(type) {
return eachAddonInvoke('treeFor', [type]).filter(Boolean);
}
var fakeApp = {
import() { }
};
project.addons.map(function(addon) { addon.app = fakeApp; });
eachAddonInvoke('included', [{ import() { }}]);
// --- Dependencies ---
var addonVendorTrees = mergeTrees(addonTreesFor('vendor'));
var loader = new Funnel(addonVendorTrees, {
srcDir: 'loader',
files: ['loader.js'],
destDir: '/assets'
});
// --- Project Files ---
var lib = new Funnel('lib', {
srcDir: '/',
include: ['**/*.js'],
destDir: '/'
});
var tests = new Funnel('tests', {
srcDir: '/',
include: ['**/*.js'],
destDir: '/tests'
});
var libESLint = eslint(lib, { testGenerator: 'qunit' });
var testESLint = eslint(tests, { testGenerator: 'qunit' });
var mainTrees = [lib, tests, libESLint, testESLint];
var addonTree = mergeTrees(addonTreesFor('addon'));
var main = mergeTrees(mainTrees);
// --- Compile ES6 modules ---
main = new Babel(main, {
loose: true,
moduleIds: true,
modules: 'amdStrict'
});
main = mergeTrees([main, addonTree]);
main = concat(main, {
inputFiles: ['**/*.js'],
outputFile: '/assets/ember-test-helpers-tests.amd.js'
});
// --- Select and concat vendor / support files ---
var inputFiles = ['jquery/dist/jquery.js',
'ember/ember-template-compiler.js',
'ember/ember.debug.js',
'FakeXMLHttpRequest/fake_xml_http_request.js',
'route-recognizer/dist/route-recognizer.js',
'pretender/pretender.js'];
if (existsSync('bower_components/ember-data/ember-data.js')) {
inputFiles.push('ember-data/ember-data.js');
}
var vendor = concat('bower_components', {
headerFiles: inputFiles,
outputFile: '/assets/vendor.js'
});
var qunit = new Funnel('bower_components', {
srcDir: '/qunit/qunit',
files: ['qunit.js', 'qunit.css'],
destDir: '/assets'
});
var testIndex = new Funnel('tests', {
srcDir: '/',
files: ['index.html'],
destDir: '/tests'
});
var testSupport = concat('bower_components', {
headerFiles: ['ember-cli-shims/app-shims.js',
'ember-cli-test-loader/test-loader.js'],
outputFile: '/assets/test-support.js'
});
return mergeTrees([main, vendor, testIndex, qunit, loader, testSupport]);
};