forked from sglanzer-deprecated/ember-cli-blanket
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
76 lines (60 loc) · 2.03 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
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
/* jshint node: true */
'use strict';
var path = require('path');
var replace = require('broccoli-replace');
module.exports = {
name: 'Ember CLI Blanket',
blueprintsPath: function() {
return path.join(__dirname, 'blueprints');
},
included: function included(app) {
this._super.included(app);
if (app.tests) {
var fileAssets = [
path.join(app.bowerDirectory, 'blanket' ,'dist', 'qunit', 'blanket.js')
];
fileAssets.forEach(function(file){
app.import(file, {
type: 'test'
});
});
}
},
postprocessTree: function(type, tree) {
this._requireBuildPackages();
if (type === 'all' && this.app.tests) {
var treeTestLoader = this.pickFiles(tree, {
files: ['test-loader.js'],
srcDir: 'assets',
destDir: 'app'
});
var tests = this.treeGenerator(path.join(this.project.root, 'tests'));
var blanketOptions = this.pickFiles(tests, {
files: ['blanket-options.js'],
srcDir: '/',
destDir: '/assets'
});
var lib = this.treeGenerator(path.join(__dirname, 'lib'));
var blanketLoader = this.pickFiles(lib, {
files: ['blanket-loader.js'],
srcDir: '/',
destDir: '/assets'
});
var qunitStart = this.pickFiles(lib, {
files: ['qunit-start.js'],
srcDir: '/',
destDir: '/'
});
var testLoaderTree = this.concatFiles(this.mergeTrees([treeTestLoader, qunitStart]), {
inputFiles: ['**/*.js'],
outputFile: '/assets/test-loader.js'
});
return this.mergeTrees([tree, blanketOptions, blanketLoader, testLoaderTree], {
overwrite: true
});
}
else {
return tree;
}
}
};