Skip to content

Add watch.sh and document it in the codelab-4-codelab sample #873

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
5 changes: 5 additions & 0 deletions sample/codelab.md
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,11 @@ $ claat serve
* Choose the directory that matches your "id" that you put in the headers.
* Viola! You should have your first codelab!

For a "tight inner loop" while writing Codelabs, you can use a tool like e.g. [`entr`](https://github.com/eradman/entr)
with a [watch script such as this one](https://github.com/googlecodelabs/tools/blob/main/sample/watch.sh); this allows
to change your Markdown source file, Ctrl-S to Save it, F5 to reload in the brower - without having to constantly retype
the commands above every time.

## Host Your CodeLab
Duration: 0:01:00

Expand Down
10 changes: 10 additions & 0 deletions sample/watch.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env bash
set -euo pipefail

# TODO Implement https://github.com/googlecodelabs/tools/issues/881 and remove this! ;-)

../claat/bin/claat serve &
claatServePID=$?
trap 'kill ${claatServePID}' EXIT

echo codelab.md | entr ../claat/bin/claat export codelab.md