Skip to content

Commit

Permalink
webview build [nfc]: make all variables readonly where possible
Browse files Browse the repository at this point in the history
  • Loading branch information
rk-for-zulip committed Nov 15, 2019
1 parent bb58cb7 commit 6487e68
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
9 changes: 6 additions & 3 deletions tools/build-webview
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export -f z_rsync
################################################################################

# Chdir to the current git repo's root.
_root="$(git rev-parse --show-toplevel)"
readonly _root="$(git rev-parse --show-toplevel)"
cd "$_root"

# Ensure that we have access to a functional `readlink -f`.
Expand Down Expand Up @@ -98,6 +98,9 @@ fi
# Make $_dest absolute, if it isn't already.
_dest=$(readlink -m "$_dest")

# Argument parsing has concluded; argument variables are no longer mutable.
readonly _target _dest _sanity_checks

# Sanity-check _dest and _target, if not explicitly disabled.
if (( _sanity_checks )); then
case "$_target" in
Expand Down Expand Up @@ -142,13 +145,13 @@ fi # if _sanity_checks

# Set _staging. This is our local staging directory; once it's assembled, it'll
# be synced over to _dest.
_staging=src/webview/static
readonly _staging=src/webview/static
if [ ! -d "$_staging" ]; then
err "cannot find asset staging directory '$_staging'";
fi

# The auxiliary build script directory.
_aux_script_dir="$_root"/tools/build-webview.d
readonly _aux_script_dir="$_root"/tools/build-webview.d

################################################################################
# Pre-sync: additional build steps
Expand Down
6 changes: 3 additions & 3 deletions tools/build-webview.d/katex.all.pre
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#!/usr/bin/env bash
set -eu

_src=${ROOT}/node_modules/katex/dist
_dest="${STAGING}/katex"
readonly _src=${ROOT}/node_modules/katex/dist
readonly _dest="${STAGING}/katex"

# KaTeX provides three versions of each of their font files: TrueType, WOFF,
# and WOFF2. WOFF2 support is available as of (iOS) Safari 10 and Chrome 36.
_katex_font_type=woff2
readonly _katex_font_type=woff2

z_rsync "${_src}/" "${_dest}" <<EOF
# Include these two files.
Expand Down

0 comments on commit 6487e68

Please sign in to comment.