forked from kriskbx/gitlab-time-tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.js
More file actions
59 lines (51 loc) · 1.33 KB
/
config.js
File metadata and controls
59 lines (51 loc) · 1.33 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
const moment = require('moment');
const dates = ['from', 'to'];
const defaults = {
url: 'https://gitlab.com/api/v4',
token: false,
project: false,
iids: false,
closed: false,
milestone: false,
hoursPerDay: 8,
columns: ['iid', 'title', 'estimation', 'times'],
dateFormat: 'Y-m-d H:i:s',
timeFormat: '[%sign][%days>d ][%hours>h ][%minutes>m ][%seconds>s]',
output: 'markdown',
excludeByLabels: false,
includeByLabels: false,
includeLabels: false,
excludeLabels: false,
query: ['issues', 'merge_requests'],
_perPage: 100,
_parallel: 4
};
class config {
constructor() {
this.data = defaults;
}
/**
* set a value by the given key.
* it won't get set if the value is null or undefined. you can force
* setting the value by passing true as third parameter.
* @param key
* @param value
* @param force
* @returns {config}
*/
set(key, value, force = false) {
if (!force && (value === null || value === undefined)) return this;
this.data[key] = value;
return this;
}
/**
* get a value by the given key
* @param key
* @returns {*}
*/
get(key) {
if (!dates.includes(key)) return this.data[key];
return moment(this.data[key]);
}
}
module.exports = config;