forked from rdmtc/RedMatic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
update_readme.js
54 lines (38 loc) · 1.68 KB
/
update_readme.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
const fs = require('fs');
const request = require('sync-request');
console.log('\nAssemble Readme files');
let out = fs.readFileSync(__dirname + '/docs/README.header.md').toString();
let res = request('GET', 'https://raw.githubusercontent.com/wiki/rdmtc/RedMatic/Intro.md');
if (res && res.statusCode === 200) {
console.log(' fetched wiki/Intro');
out += res.body.toString();
}
out += '\n## Dokumentation\n\n';
res = request('GET', 'https://raw.githubusercontent.com/wiki/rdmtc/RedMatic/Home.md');
if (res && res.statusCode === 200) {
console.log(' fetched wiki/Home');
let toc = res.body.toString();
toc = toc.replace(/^.*\(Intro\)\n/, '');
toc = toc.replace(/]\((?!http)/g, '](https://github.com/rdmtc/RedMatic/wiki/');
out += toc;
}
out += '\n\n\n' + fs.readFileSync(__dirname + '/docs/README.footer.md').toString();
fs.writeFileSync('README.md', out);
out = fs.readFileSync(__dirname + '/docs/README.header.en.md').toString();
res = request('GET', 'https://raw.githubusercontent.com/wiki/rdmtc/RedMatic/en:Intro.md');
if (res && res.statusCode === 200) {
console.log(' fetched wiki/en:Intro');
out += res.body.toString();
}
out += '\n## Documentation\n\n';
res = request('GET', 'https://raw.githubusercontent.com/wiki/rdmtc/RedMatic/en:Home.md');
if (res && res.statusCode === 200) {
console.log(' fetched wiki/en:Home');
let toc = res.body.toString();
toc = toc.replace(/^.*\(Intro\)\n/, '');
toc = toc.replace(/]\((?!http)/g, '](https://github.com/rdmtc/RedMatic/wiki/');
out += toc;
}
out += '\n\n\n' + fs.readFileSync(__dirname + '/docs/README.footer.en.md').toString();
fs.writeFileSync('README.en.md', out);
console.log(' done.');