-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
121 lines (121 loc) · 3.59 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
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
114
115
116
117
118
119
120
121
module.exports = function(promisedRequire, resolve, register, config, containerlike)
{
var name = __dirname;
var id = "willow.";
config = name + "/conf/javascript.js"; // js
if(promisedRequire == null) {
//probably testing
var $require = require;
var promised = $require("./util/promised");
promisedRequire = promised(
function(path)
{
return require(path.replace(name, "./"));
}
);
}
var modules = [
"Builder.js",
"filters/index.js", // js
"conf/index.js"
];
if(containerlike == null) {
modules.push("Container.js");
}
return Promise.all(
modules.map(
function(item)
{
return promisedRequire(name + "/" + item);
}
)
).then(
function(modules)
{
var container = containerlike == null ? new modules[3]() : containerlike;
// js
container.set(
id + "system.import",
function()
{
return promisedRequire;
}
);
container.set(
id + "system.resolve",
function()
{
return resolve;
}
);
container.set(
id + "system.registerDynamic",
function()
{
return register;
}
);
// js
var builder = new modules[0](
container,
promisedRequire // for importing
);
return modules[1](container).then(
function(filters)
{
var container = builder.use(
filters
).getContainer();
// js
container.set(
id + "resolve.resolve",
function()
{
return builder.get(id + "resolver")("resolve");
}
);
// js
return builder;
}
).then(
function(builder)
{
var filters = modules[2]();
return builder.load(filters).then(
function()
{
return Promise.all(
Object.keys(filters).map(
function(key, i, arr)
{
return builder.get(key);
}
)
).then(
function(filters)
{
return builder;
}
);
}
);
}
).then(
function(builder)
{
return builder.load(config);
}
).then(
function(builder)
{
return Promise.all(builder.getTagged(id + "filter")).then(
function()
{
return builder;
}
);
}
);
}
);
};