Skip to content

Commit

Permalink
[#1] guard markdown contents
Browse files Browse the repository at this point in the history
  • Loading branch information
feelform committed Nov 9, 2021
1 parent c0c14b4 commit d88c5bb
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/actions/markdown-template-engine-action/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const run = async () => {

const markdownContent = await engine.markdownContent(githubRelease)
const disableChanges = core.getInput('disable_sync_changes')
if (disableChanges.length == 0) {
if (markdownContent && disableChanges.length == 0) {
fs.outputFileSync(templateMarkdownFile, markdownContent)
}
core.setOutput('markdown', markdownContent)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class MarkdownContents {
}
const match = RegExp(`^<!--\\s<${filename}>\\s-->$\\s(?<body>[\\s\\S]*)^<!--\\s<\\/${filename}>\\s-->`, 'gm').exec(readmeGithubBody)
if (!match) {
return new MarkdownContents('')
return new MarkdownContents()
}
return new MarkdownContents(match.groups.body)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ class TemplateEngine {
let result = this.template
while ((tag = tagExpression.exec(this.template)) !== null) {
const markdownFile = await this.markdownContentFromGithub(tag[1], githubRelease)
if (!markdownFile) {
return
}
result = result.replace(RegExp(`<!--\\s<${tag[1]}>\\s-->\\n[\\s\\S]*<!--\\s<\\/${tag[1]}>\\s-->`, 'm'), `<!-- <${tag[1]}> -->\n${markdownFile}\n<!-- </${tag[1]}> -->`)
}
return result
Expand Down

0 comments on commit d88c5bb

Please sign in to comment.