From ff5cbb32524e613e47f01669ed12dba46d41e403 Mon Sep 17 00:00:00 2001 From: Michael Vorburger Date: Sun, 29 Oct 2023 02:06:02 +0200 Subject: [PATCH] Add sample/watch.sh and document it in the codelab-4-codelab sample (pending #881) --- sample/codelab.md | 5 +++++ sample/watch.sh | 10 ++++++++++ 2 files changed, 15 insertions(+) create mode 100755 sample/watch.sh diff --git a/sample/codelab.md b/sample/codelab.md index d980a115b..7829cd8fc 100644 --- a/sample/codelab.md +++ b/sample/codelab.md @@ -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 diff --git a/sample/watch.sh b/sample/watch.sh new file mode 100755 index 000000000..3d7895eaa --- /dev/null +++ b/sample/watch.sh @@ -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