forked from adopted-ember-addons/ember-electron
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
76 lines (61 loc) · 1.83 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
'use strict';
const fs = require('fs-extra');
const path = require('path');
const assembleTree = require('./lib/utils/assemble-tree');
function injectScript(scriptName) {
let dirname = __dirname || process.cwd();
let filePath = path.join(dirname, 'lib', 'resources', scriptName);
let fileContent = fs.readFileSync(filePath, { encoding: 'utf8' });
return `<script>\n${fileContent}</script>`;
}
module.exports = {
name: 'ember-electron',
included(app) {
this._super.included(app);
if (!process.env.EMBER_CLI_ELECTRON) {
return;
}
if (app.env === 'development') {
app.import('vendor/electron/reload.js');
}
},
includedCommands() {
return {
'electron': require('./lib/commands/electron'),
'electron:test': require('./lib/commands/test'),
'electron:build': require('./lib/commands/build'),
'electron:assemble': require('./lib/commands/assemble'),
'electron:package': require('./lib/commands/package'),
'electron:make': require('./lib/commands/make'),
};
},
treeForVendor() {
let dirname = __dirname || process.cwd();
return path.join(dirname, 'app');
},
postprocessTree(type, tree) {
// Check if we're supposed to be assembling as part of the build
if (type === 'all' && process.env.EMBER_CLI_ELECTRON_ASSEMBLE) {
tree = assembleTree({
ui: this.ui,
project: this.project,
platform: process.env.EMBER_CLI_ELECTRON_PLATFORM,
inputNode: tree,
});
}
return tree;
},
contentFor(type) {
const { env: { EMBER_CLI_ELECTRON } } = process;
if (EMBER_CLI_ELECTRON) {
let script = {
'head': 'shim-head.js',
'test-head': 'shim-test-head.js',
'body-footer': 'shim-footer.js',
}[type];
if (script) {
return injectScript(script);
}
}
},
};