Telegram Web K with changes to work inside I2P https://web.telegram.i2p/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

50 lines
1.3 KiB

/*
* https://github.com/morethanwords/tweb
* Copyright (C) 2019-2021 Eduard Kuzmenko
* https://github.com/morethanwords/tweb/blob/master/LICENSE
*/
// @ts-check
const fs = require('fs');
const fileNames = fs.readdirSync('./');
const logsPath = './public/changelogs/';
fs.rmSync(logsPath, {force: true, recursive: true});
fs.mkdirSync(logsPath);
const processChangelog = (fileName) => {
const text = fs.readFileSync('./' + fileName).toString('utf-8');
3 years ago
const lang = (fileName.split('_')[1] || 'en').split('.')[0];
const writeTo = `${logsPath}${lang}_{VERSION}.md`;
const separator = '### ';
const splitted = text.split(separator);
splitted.forEach(text => {
if(!text.trim()) return;
text = separator + text;
text = text.replace(/^\*/gm, '•');
const splitted = text.split('\n');
for(let i = splitted.length - 1; i >= 0; --i) {
const line = splitted[i];
if(!line.trim()) {
splitted.splice(i, 1);
} else {
break;
}
3 years ago
}
const firstLine = splitted.shift();
const version = firstLine.split(' ')[1];
fs.writeFileSync(writeTo.replace('{VERSION}', version), splitted.join('\n') + '\n');
});
};
3 years ago
fileNames.forEach(fileName => {
if(fileName.endsWith('.md') && fileName.startsWith('CHANGELOG')) {
processChangelog(fileName);
}
});