forked from Gottwik/Enduro
-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
58 lines (45 loc) · 2.64 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
// * ———————————————————————————————————————————————————————— * //
// * enduro.js
// * Minimalistic, lean & mean, node.js cms
// * ———————————————————————————————————————————————————————— * //
// * vendor dependencies
const Promise = require('bluebird')
// * enduro dependencies
const linker = require('./libs/linker/linker')
const enduro_instance = function () {}
// * ———————————————————————————————————————————————————————— * //
// * quick_init
// *
// * sets up limited global variables such as enduro's location
// * this is used mainly to speed up tests where all enduro's variables
// * are not needed
// * @return nothing
// * ———————————————————————————————————————————————————————— * //
enduro_instance.prototype.quick_init = function () {
// exposes enduro api, state, variables and configuration as public variable
global.enduro = linker.init_enduro_linked_configuration(process.cwd(), __dirname)
return this // returns self chain-style in case the full init is needed later
}
// * ———————————————————————————————————————————————————————— * //
// * init
// *
// * - sets up global enduro variables
// * - exposes enduro's api to client project
// * - exposes enduro's main action
// * - read and stores project-specific configuration
// * @return {Promise} - resolves after enduro is ready to start
// * ———————————————————————————————————————————————————————— * //
enduro_instance.prototype.init = function (settings) {
settings = settings || {}
const new_project_path = settings.project_path || process.cwd()
// exposes enduro api, state, variables and configuration as public variable
global.enduro = linker.init_enduro_linked_configuration(new_project_path, __dirname, settings.flags)
// exposes enduro's api libraries and action functions
linker.expose_enduro_api()
// these two are asynchronous, so let's do them in parallel
return Promise.all([
linker.expose_enduro_actions(), // actions are stored in /libs/actions/
linker.read_config()
])
}
module.exports = new enduro_instance()