-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
58 lines (48 loc) · 1.65 KB
/
index.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
const fs = require('fs');
const { promisify } = require('util');
const readFile = promisify(fs.readFile);
const writeFile = promisify(fs.writeFile);
const { loadSickPicksWithMatchString } = require('./getShows');
const getSickPicksAndWriteToReadme = async () => {
const podcastSickPicks = await loadSickPicksWithMatchString('podcast');
const youtubeSickPicks = await loadSickPicksWithMatchString('youtube');
const currentReadme = await readFile('./README.md', 'utf8');
const staticReadmeContent = currentReadme.split('<!-- dynamic_content_below -->')[0];
const dynamicPodcastLines = [
'# Sick Picked Podcasts',
'',
'Name | Link | Sick Pick by',
'--- | --- | ---',
];
podcastSickPicks.forEach(podcast => {
let title = podcast.title;
if (title.length > 30) {
title = `${title.substr(0, 29)}...`;
}
dynamicPodcastLines.push(`${title} | [Click me](${podcast.url}) | ${podcast.sickPickBy}`);
});
const dynamicYoutubeLines = [
'# Sick Picked Youtube Videos or Channels',
'',
'Name | Link | Sick Pick by',
'--- | --- | ---',
];
youtubeSickPicks.forEach(youtubeVideo => {
let title = youtubeVideo.title;
if (title.length > 30) {
title = `${title.substr(0, 29)}...`;
}
dynamicYoutubeLines.push(`${title} | [Click me](${youtubeVideo.url}) | ${youtubeVideo.sickPickBy}`);
});
const finalReadMeString =
staticReadmeContent +
'<!-- dynamic_content_below -->' +
'\n' +
dynamicPodcastLines.join('\n') +
'\n' +
dynamicYoutubeLines.join('\n');
await writeFile('./README.md', finalReadMeString);
}
(async () => {
await getSickPicksAndWriteToReadme();
})();