read readme changes

This commit is contained in:
2022-06-08 09:13:04 -05:00
parent ffe6969889
commit 69d8ee884e
3 changed files with 33 additions and 15 deletions

View File

@@ -36,15 +36,23 @@ function getReadmeFileName() {
}
function readReadmeFile(readmeFile) {
let content = (0, fs_1.readFileSync)(readmeFile).toString();
const regex = /<!-- START INSTALL LINKS -->(?:.|\n)*?<!-- END INSTALL LINKS -->/;
const regex = /\n{0,1}<!-- START INSTALL LINKS -->(?:.|\n)*?<!-- END INSTALL LINKS -->\n{0,1}/;
const index = regex.exec(content)?.index;
let contentPre = '', contentPost = '';
if (index === undefined) {
if (!content.endsWith('\n')) {
content += '\n';
}
return [content, ''];
contentPre = content;
}
content = content.replace(regex, '');
return [content.slice(0, index), content.slice(index)];
else {
content = content.replace(regex, '');
contentPre = content.slice(0, index);
contentPost = content.slice(index);
}
if (!contentPre.endsWith('\n')) {
contentPre += '\n';
}
if (!contentPost.endsWith('\n')) {
contentPost += '\n';
}
return [contentPre, contentPost];
}
//# sourceMappingURL=readmefile.js.map