-
Notifications
You must be signed in to change notification settings - Fork 2
/
config.js
45 lines (41 loc) · 2.49 KB
/
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
39
40
41
42
43
44
45
var fs = require('fs');
this.configData = {};
try {
this.configData = require('./config.json');
console.log(' -=- > Loading configuration from config.json');
}
catch (e) {
console.log(' -=- > Loading configuration from environment variables');
}
// Pull this in now to allow either file-based config (checked second) or environment variables (checked first)
var runtimeOptions = {
mentionName: process.env.MENTION_NAME || this.configData.mentionName,
hipchatUser: process.env.HIPCHAT_USER || this.configData.hipchatUser,
hipchatPassword: process.env.HIPCHAT_PASSWORD || this.configData.hipchatPassword,
hipchatApi: process.env.HIPCHAT_API || this.configData.hipchatApi,
tracker: process.env.TRACKER || this.configData.tracker,
modules: process.env.MODULES || this.configData.modules,
debug: process.env.NODE_DEBUG || this.configData.debug || false,
giphyKey: process.env.GIPHY_KEY || this.configData.giphyKey,
baseDir: process.env.BASE_DIR || this.configData.baseDir,
ansibleDir: process.env.ANSIBLE_DIR || this.configData.ansibleDir,
authAnsiblers: process.env.AUTH_ANSIBLERS || this.configData.authAnsiblers
};
// Are we connecting to BitBucket? Otherwise, assume JIRA.
if (runtimeOptions.tracker == 'bitbucket'){
runtimeOptions.bitBucketUrl = process.env.BITBUCKET_URL || this.configData.bitBucketUrl;
runtimeOptions.bbOwner = process.env.BB_OWNER || this.configData.bbOwner;
runtimeOptions.bbUsername = process.env.BB_USERNAME || this.configData.bbUsername;
runtimeOptions.bbPassword = process.env.BB_PASSWORD || this.configData.bbPassword;
runtimeOptions.bbProjectRe = process.env.BB_PROJECT_RE || this.configData.bbProjectRe;
runtimeOptions.bbProjectPullRe = process.env.BB_PROJECT_PULL_RE || this.configData.bbProjectPullRe;
} else {
runtimeOptions.jiraBrowseUrl = process.env.JIRA_BROWSE_URL || this.configData.jiraBrowseUrl;
runtimeOptions.jiraHostname = process.env.JIRA_HOSTNAME || this.configData.jiraHostname;
runtimeOptions.jiraUsername = process.env.JIRA_USERNAME || this.configData.jiraUsername;
runtimeOptions.jiraPassword = process.env.JIRA_PASSWORD || this.configData.jiraPassword;
runtimeOptions.jiraProjectRe = new RegExp(process.env.JIRA_PROJECT_RE, "gi") || new RegExp(this.configData.jiraProjectRe, "gi");
};
runtimeOptions.hipchatRoomsToJoin = new Array();
runtimeOptions.hipchatRoomsToJoin = process.env.HIPCHAT_ROOMS_TO_JOIN ? process.env.HIPCHAT_ROOMS_TO_JOIN.split(',') : this.configData.hipchatRoomsToJoin;
module.exports = runtimeOptions;