forked from haraka/Haraka
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.js
38 lines (33 loc) · 932 Bytes
/
config.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 configloader = require('./configfile');
var path = require('path');
var logger = require('./logger');
var config = exports;
var config_path = process.env.HARAKA ? path.join(process.env.HARAKA, 'config') : './config';
config.get = function(name, type) {
if (type !== 'nolog') {
logger.loginfo("Getting config: " + name);
}
else {
type = arguments[2];
}
var full_path = path.resolve(config_path, name);
var results;
try {
results = configloader.read_config(full_path, type);
}
catch (err) {
if (err.code === 'EBADF') {
// do nothing
if (type === 'ini') {
return configloader.empty_config(type);
}
else {
return null;
}
}
else {
logger.logerror(err.name + ': ' + err.message);
}
}
return results;
};