Skip to content

Commit

Permalink
πŸ”¨ Fix guestbook comment replacement
Browse files Browse the repository at this point in the history
  • Loading branch information
joshmgross committed Jun 26, 2020
1 parent 5266b84 commit 6eab2c1
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 15 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 "[email protected]"
git config --local user.name "${{ github.actor }}"
git add README.md
git add guestbook.md
git commit -m "✏ Update guestbook"
git push
fi
14 changes: 5 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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. πŸ§€
<sup>[src](https://github.com/joshmgross/guestbook/issues/1#issuecomment-645117859)</sup>
```
<!--START:guestbook-->

## Example Guestbook
<!--END: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. πŸ§€
<sup>[src](https://github.com/joshmgross/guestbook/issues/1#issuecomment-645117859)</sup>
See [guestbook.md](./guestbook.md) for an example guestbook.

## Prior Art 🎨

Expand Down
3 changes: 2 additions & 1 deletion dist/book.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
3 changes: 2 additions & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
7 changes: 7 additions & 0 deletions guestbook.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Example Guestbook

This guestbook is populated by approved :+1: comments in https://github.com/joshmgross/guestbook/issues/1.

<!--START:guestbook-->

<!--END:guestbook-->
3 changes: 2 additions & 1 deletion src/book.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

0 comments on commit 6eab2c1

Please sign in to comment.