on bce304a help sign in
bat/assets/create.sh
63 lines 1.7 kB history raw
1#!/usr/bin/env bash
2set -euo pipefail
4ASSET_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
5REPO_DIR="$ASSET_DIR/.."
7# Ensure submodules are initialized.
8function update_submodules() {
9 local submodule
10 local submodule_prompt=unspecified
11 local submodule_path
13 {
14 while { read -r submodule && read -r submodule_path; } <&3; do
15 if ! [[ -d "${REPO_DIR}/.git/modules/${submodule}" ]] && [[ -d "${REPO_DIR}/${submodule_path}" ]]; then
16 if [[ "$submodule_prompt" = "unspecified" ]]; then
17 echo "One or more submodules were found to be uninitialized."
18 printf "Initialize and update them? [Y/n] "
19 read -r submodule_prompt
20 fi
22 case "$submodule_prompt" in
23 y|yes|'') {
24 git -C "$REPO_DIR" submodule update --init "$submodule_path"
25 };;
26 n|no) {
27 return
28 };;
29 *) {
30 echo "Unknown answer. Not updating submodules."
31 };;
32 esac
33 fi
34 done
35 } 3< <(git config --file "${REPO_DIR}/.gitmodules" --null --get-regexp path | xargs -0 printf "%s\n" | sed 's/^submodule.//;s/.path$//')
38if [ -t 0 ]; then
39 update_submodules
40fi
42# Always remove the local cache to avoid any confusion
43bat cache --clear
45# TODO:
46# - Remove the JavaDoc patch once https://github.com/trishume/syntect/issues/222 has been fixed
47# - Remove the C# patch once https://github.com/sublimehq/Packages/pull/2331 has been merged
50 cd "$ASSET_DIR"
51 for patch in patches/*.patch; do
52 patch --strip=0 < "$patch"
53 done
56bat cache --build --blank --source="$ASSET_DIR" --target="$ASSET_DIR"
59 cd "$ASSET_DIR"
60 for patch in patches/*.patch; do
61 patch --strip=0 --reverse < "$patch"
62 done