read readme changes
This commit is contained in:
@@ -46,16 +46,26 @@ function getReadmeFileName(): string | null {
|
||||
function readReadmeFile(readmeFile: string): [string, string] {
|
||||
let content = readFileSync(readmeFile).toString()
|
||||
const regex =
|
||||
/<!-- START INSTALL LINKS -->(?:.|\n)*?<!-- END INSTALL LINKS -->/
|
||||
/\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
|
||||
} else {
|
||||
content = content.replace(regex, '')
|
||||
contentPre = content.slice(0, index)
|
||||
contentPost = content.slice(index)
|
||||
}
|
||||
|
||||
content = content.replace(regex, '')
|
||||
return [content.slice(0, index), content.slice(index)]
|
||||
if (!contentPre.endsWith('\n')) {
|
||||
contentPre += '\n'
|
||||
}
|
||||
if (!contentPost.endsWith('\n')) {
|
||||
contentPost += '\n'
|
||||
}
|
||||
|
||||
return [contentPre, contentPost]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user