-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathjsLoader.js
More file actions
40 lines (39 loc) · 1.16 KB
/
jsLoader.js
File metadata and controls
40 lines (39 loc) · 1.16 KB
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
'use strict';
module.exports = {
extension: '.js',
loader: configFile => {
const config = require(configFile);
let _extends, load, merge, postload;
if (typeof config === 'function') {
load = config;
} else if (typeof config === 'object') {
if (typeof config.extends === 'string' || Array.isArray(config.extends)) {
_extends = config.extends;
}
if (typeof config.merge === 'boolean') {
merge = config.merge;
}
if (typeof config.load === 'object') {
load = () => config.load;
} else if (typeof config.load === 'function') {
load = config.load;
}
if (typeof config.postload === 'object') {
postload = () => config.postload;
} else if (typeof config.postload === 'function') {
postload = config.postload;
}
if (_extends === undefined && load === undefined && merge === undefined && postload === undefined) {
load = () => config;
}
} else {
throw new Error(`Can't load configuration from ${configFile}.`);
}
return {
extends: _extends,
load: load,
merge: merge,
postload: postload
};
}
};