-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
74 lines (55 loc) · 1.78 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
/* jshint node: true */
'use strict';
module.exports = {
name: 'telling-stories',
included: function(app) {
// see: https://github.com/ember-cli/ember-cli/issues/3718
if (typeof app.import !== 'function' && app.app) {
app = app.app;
}
this.app = app;
if (!this.shouldIncludeFiles()) {
return;
}
this.isGeneratingSite = !!process.env['TELLING_STORIES'];
this._super.included.apply(this, arguments);
app.import('vendor/telling-stories/qunit-configuration.js', { type: 'test', prepend: true });
app.import('vendor/telling-stories/player-mode.css', { type: 'test' });
},
postBuild: function(result) {
if (!this.isGeneratingSite) {
return;
}
var dir = result.directory;
var fs = require('fs');
var path = require('path');
fs.unlinkSync(path.resolve(dir, 'index.html'));
fs.renameSync(path.resolve(dir, 'tests/index.html'), path.resolve(dir, 'runner.html'));
fs.renameSync(path.resolve(dir, 'telling-stories/viewer.html'), path.resolve(dir, 'index.html'));
},
treeFor: function() {
if (!this.shouldIncludeFiles()) {
return;
}
return this._super.treeFor.apply(this, arguments);
},
treeForPublic: function() {
if (!this.isGeneratingSite) {
return;
}
var publicTree = this._super.treeForPublic.apply(this, arguments);
var CreateListOfTests = require('./lib/create-list-of-tests');
var testListTree = new CreateListOfTests('tests');
var BroccoliMergeTrees = require('broccoli-merge-trees');
return new BroccoliMergeTrees([publicTree, testListTree]);
},
isDevelopingAddon: function() {
return true;
},
shouldIncludeFiles: function() {
return !!this.app.tests;
},
includedCommands: function() {
return require('./lib/commands');
}
};