Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scripts: merge removeAnchors.sh and resetSolutions.sh #457

Merged
merged 3 commits into from
Sep 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,8 @@ jobs:
- name: Run tests
run: ./scripts/testAll.sh

- name: Remove anchors
run: ./scripts/removeAnchors.sh

- name: Run tests again
run: ./scripts/testAll.sh

- name: Reset solutions
run: ./scripts/resetSolutions.sh
- name: Prepare exercises
run: ./scripts/prepareExercises.sh

- name: Run tests again
run: ./scripts/testAll.sh
Expand Down
28 changes: 28 additions & 0 deletions scripts/prepareExercises.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env bash

# This script removes meta information that is not intended for readers of the book

# Echo commands to shell
set -x
# Exit on first failure
set -e

# For all chapters
for d in exercises/chapter*; do
# All .purs & .js files of chapter exercises
FILES=$(find $d/src $d/test -name '*.purs' -o -name '*.js')

for f in $FILES; do
# Delete lines starting with an 'ANCHOR' comment
perl -ni -e 'print if !/^\s*(--|\/\/) ANCHOR/' $f

# Delete lines with a note to delete them
perl -ni -e 'print if !/This line should have been automatically deleted/' $f
done

# If there's a no-peeking directory
if [ -d $d/test/no-peeking ]; then
# Move 'no-peeking' sources out of the compilation path
mv $d/test/no-peeking $d
fi
done
23 changes: 0 additions & 23 deletions scripts/removeAnchors.sh

This file was deleted.

22 changes: 0 additions & 22 deletions scripts/resetSolutions.sh

This file was deleted.

5 changes: 2 additions & 3 deletions text/chapter2.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,11 @@ Now that you've installed the necessary development tools, clone this book's rep
git clone https://github.com/purescript-contrib/purescript-book.git
```

The book repo contains PureScript example code and unit tests for the exercises that accompany each chapter. There's some initial setup required to reset the exercise solutions so they are ready to be solved by you. Use the `resetSolutions.sh` script to simplify this process. While at it, you should also strip out all the anchor comments with the `removeAnchors.sh` script (these anchors are used for copying code snippets into the book's rendered markdown, and you probably don't need this clutter in your local repo):
The book repo contains PureScript example code and unit tests for the exercises that accompany each chapter. There's some initial setup required to reset the exercise solutions so they are ready to be solved by you. Use the `prepareExercises.sh` script to simplify this process:

```sh
cd purescript-book
./scripts/resetSolutions.sh
./scripts/removeAnchors.sh
./scripts/prepareExercises.sh
git add .
git commit --all --message "Exercises ready to be solved"
```
Expand Down
Loading