From 6eab2c1c9dceda6acbd76d80a1c7bf1ba7eba8bd Mon Sep 17 00:00:00 2001 From: Josh Gross Date: Fri, 26 Jun 2020 02:42:33 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A8=20Fix=20guestbook=20comment=20repl?= =?UTF-8?q?acement?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/main.yml | 5 ++--- README.md | 14 +++++--------- dist/book.js | 3 ++- dist/index.js | 3 ++- guestbook.md | 7 +++++++ src/book.ts | 3 ++- 6 files changed, 20 insertions(+), 15 deletions(-) create mode 100644 guestbook.md diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 325332e..d244ddb 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -17,14 +17,13 @@ jobs: issue: 1 approvers: | joshmgross - - run: cat README.md - + guestbook-path: guestbook.md - name: Update guestbook run: | if [[ `git status --porcelain` ]]; then git config --local user.email "actions@github.com" git config --local user.name "${{ github.actor }}" - git add README.md + git add guestbook.md git commit -m "✏ Update guestbook" git push fi diff --git a/README.md b/README.md index 90062f2..547ece7 100644 --- a/README.md +++ b/README.md @@ -39,18 +39,14 @@ See [main.yml](.github/workflows/main.yml) for a full workflow file example. In your guestbook markdown file, add comments to denote the start and end of the guestbook. Everything within these comments will be replaced by approved comments from the issue specified. ```md -[@joshmgross](https://github.com/joshmgross) said: -> Hello, this is an informative and useful comment illustrating my thoughts. 🧀 -[src](https://github.com/joshmgross/guestbook/issues/1#issuecomment-645117859) -``` + -## Example Guestbook + +``` -This guestbook is populated by approved :+1: comments in https://github.com/joshmgross/guestbook/issues/1. +# Example Guestbook -[@joshmgross](https://github.com/joshmgross) said: -> Hello, this is an informative and useful comment illustrating my thoughts. 🧀 -[src](https://github.com/joshmgross/guestbook/issues/1#issuecomment-645117859) +See [guestbook.md](./guestbook.md) for an example guestbook. ## Prior Art 🎨 diff --git a/dist/book.js b/dist/book.js index 2c6c059..724d254 100644 --- a/dist/book.js +++ b/dist/book.js @@ -41,7 +41,8 @@ function createGuestbookList(comments) { function generateGuestbook(path, comments) { const guestbook = getReadme(path); const guestbookList = createGuestbookList(comments); - const updatedGuestbook = guestbook.replace(commentSectionRegex, guestbookList); + const guestbookContent = `${startComment}\n${guestbookList}\n${endComment}`; + const updatedGuestbook = guestbook.replace(commentSectionRegex, guestbookContent); writeReadme(path, updatedGuestbook); } exports.generateGuestbook = generateGuestbook; diff --git a/dist/index.js b/dist/index.js index 7e2da38..17418d1 100644 --- a/dist/index.js +++ b/dist/index.js @@ -9490,7 +9490,8 @@ function createGuestbookList(comments) { function generateGuestbook(path, comments) { const guestbook = getReadme(path); const guestbookList = createGuestbookList(comments); - const updatedGuestbook = guestbook.replace(commentSectionRegex, guestbookList); + const guestbookContent = `${startComment}\n${guestbookList}\n${endComment}`; + const updatedGuestbook = guestbook.replace(commentSectionRegex, guestbookContent); writeReadme(path, updatedGuestbook); } exports.generateGuestbook = generateGuestbook; diff --git a/guestbook.md b/guestbook.md new file mode 100644 index 0000000..425d553 --- /dev/null +++ b/guestbook.md @@ -0,0 +1,7 @@ +# Example Guestbook + +This guestbook is populated by approved :+1: comments in https://github.com/joshmgross/guestbook/issues/1. + + + + \ No newline at end of file diff --git a/src/book.ts b/src/book.ts index b5f5094..7feff4b 100644 --- a/src/book.ts +++ b/src/book.ts @@ -27,6 +27,7 @@ function createGuestbookList(comments: Comment[]): string { export function generateGuestbook(path: string, comments: Comment[]): void { const guestbook = getReadme(path); const guestbookList = createGuestbookList(comments); - const updatedGuestbook = guestbook.replace(commentSectionRegex, guestbookList); + const guestbookContent = `${startComment}\n${guestbookList}\n${endComment}`; + const updatedGuestbook = guestbook.replace(commentSectionRegex, guestbookContent); writeReadme(path, updatedGuestbook); }