forked from devtyr/trello-burndown
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrun.js
42 lines (34 loc) · 1.36 KB
/
run.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
/*
* Trello burndown chart generator
*
* Author: Norbert Eder <[email protected]>
*/
var fs = require('fs');
var path = require('path');
global.settings = require('./settings');
settings.root = __dirname.replace(/\/+$/, "");
settings.exportPath = path.join(settings.root, 'export');
settings.configPath = path.join(settings.root, 'config');
settings.templatePath = path.join(settings.root, 'templates');
settings.sprintTemplatePath = path.join(settings.root, 'templates' + path.sep + settings.template);
settings.homeTemplatePath = path.join(settings.root, 'templates' + path.sep + settings.home_template);
if (process.env.PORT) settings.port = process.env.PORT;
// if export path does not exist, create it
if (!fs.existsSync(settings.exportPath)) {
fs.mkdirSync(settings.exportPath);
}
// if config path does not exist, create it
if (!fs.existsSync(settings.configPath)) {
fs.mkdirSync(settings.configPath);
}
var server = require('./lib/server');
if (settings.useHttpAuth) {
var basicAuth = require('http-auth').basic({
realm: "Burndown."
}, (username, password, callback) => {
callback(username === settings.httpUsername && password === settings.httpPassword)
})
require('http').createServer(basicAuth, (server)).listen(settings.port);
} else {
require('http').createServer(server).listen(settings.port);
}