-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.js
67 lines (57 loc) · 1.65 KB
/
build.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
'use strict';
const fs = require('fs');
const obj = require('./events.json');
let content = '# Events & Conferences\nA list of events and conferences you can find the Front End Happy Hour panelists at.';
const events2016 = [];
const events2017 = [];
let newObj;
// create list of events
for (const event of obj) {
let who = '';
for (let i = 0; i < event.who.length; i++){
if(i + 1 < event.who.length) {
who += event.who[i] + ', ';
}else {
who += event.who[i];
}
}
// create an object of the event details
newObj = {
'event': event.event,
'url': event.url,
'where': event.where,
'date': event.date,
'year': event.year,
'who': who,
'desc': event.desc
};
// add 2016 events to new object
if(event.year === '2016') {
events2016.push(newObj);
}else if(event.year === '2017') {
events2017.push(newObj);
}
}
// content details displayed on the readme
let readmeContent = (event, url, where, date, who, desc) => {
return `\n## [${event}](${url})\n
**Where:** ${where}\n
**When:** ${date}\n
**Attending:** ${who}\n
${desc}\n\n`
}
// create a heading for the year
content += '\n# 2017\n';
for (const event of events2017) {
content += readmeContent(event.event, event.url, event.where, event.date, event.who, event.desc);
}
// create a heading for the year
content += '\n\n# 2016\n';
for (const event of events2016) {
content += readmeContent(event.event, event.url, event.where, event.date, event.who, event.desc);
}
// create README with the list of conferences
fs.writeFile('./README.md', content, function (err) {
if (err) throw err;
console.log('Updated event list');
});