forked from mendix/hybrid-app-base
-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils.js
38 lines (33 loc) · 1.1 KB
/
utils.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
var fs = require("fs");
var path = require("path");
module.exports = (function() {
var loadConfigFile = function(absolute_path) {
try {
return require(absolute_path);
} catch (ex) {
return {};
}
};
var getBaseOrCustomPath = function(partial_path) {
return fs.existsSync(path.join(process.cwd(), partial_path)) ?
path.join(process.cwd(), partial_path) :
path.join(__dirname, partial_path);
};
var getBaseAndCustomPaths = function(partial_path) {
return [
path.join(process.cwd(), partial_path),
path.join(__dirname, partial_path)
]
};
var loadConfiguration = function(partial_path) {
return Object.assign({},
loadConfigFile(path.join(__dirname, partial_path)),
loadConfigFile(path.join(process.cwd(), partial_path))
);
};
return {
getBaseOrCustomPath: getBaseOrCustomPath,
getBaseAndCustomPaths: getBaseAndCustomPaths,
loadConfiguration: loadConfiguration
};
})();