2022-12-09 23:18:35 -05:00
|
|
|
const fs = require('fs');
|
|
|
|
|
|
|
|
const argv = process.argv.slice(2);
|
|
|
|
|
2022-12-09 23:20:40 -05:00
|
|
|
async function init() {
|
2022-12-09 23:18:35 -05:00
|
|
|
const content = fs.readFileSync('README.md', 'utf8').split('\n');
|
|
|
|
const startRe = /<!-- download start -->/;
|
|
|
|
const endRe = /<!-- download end -->/;
|
|
|
|
|
|
|
|
let flag = false;
|
|
|
|
for (let i = 0; i < content.length; i++) {
|
|
|
|
if (startRe.test(content[i])) {
|
|
|
|
flag = true;
|
|
|
|
}
|
|
|
|
if (flag) {
|
|
|
|
content[i] = content[i].replace(/(\d+).(\d+).(\d+)/g, argv[0]);
|
|
|
|
}
|
|
|
|
if (endRe.test(content[i])) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fs.writeFileSync('README.md', content.join('\n'), 'utf8');
|
|
|
|
}
|
|
|
|
|
2022-12-09 23:20:40 -05:00
|
|
|
init().catch(console.error);
|