diff --git a/.gitignore b/.gitignore index 93e63d7..d5e123b 100644 --- a/.gitignore +++ b/.gitignore @@ -107,4 +107,4 @@ dist public/ submodules/* -!submodules/.gitkeep +!submodules/update.sh diff --git a/submodules/.gitkeep b/submodules/.gitkeep deleted file mode 100644 index 217e56b..0000000 --- a/submodules/.gitkeep +++ /dev/null @@ -1,12 +0,0 @@ -# This `submodules` directory exists to hold external projects, but without using -# Git's submodule functionality (because they're kind of a pain in the ass to use). - -# To initialize the submodules needed to build the website, run the following -# commands in this directory. - -git clone git@git.holllo.cc/Bauke/userstyles.git -cd userstyles -yarn --silent - -# Then, if they ever need to be updated, just pull the changes and run Yarn -# again, if necessary. diff --git a/submodules/update.sh b/submodules/update.sh new file mode 100755 index 0000000..3f35e00 --- /dev/null +++ b/submodules/update.sh @@ -0,0 +1,38 @@ +#!/usr/bin/env bash + +set -e + +# This `submodules` directory exists to hold external projects, but without using +# Git's submodule functionality (because they're kind of a pain in the ass to use). + +# To initialize the submodules needed to build the website, just execute +# this file from the directory it's in with `./update.sh`. +# Then, if they ever need to be updated, just execute this file again. + +update() { + repo=$1 + directory=$2 + + echo "[$directory] $repo" + + if [ -d "$directory" ]; then + echo "[$directory] Pulling Git commits." + cd $directory + git pull + else + echo "[$directory] Cloning Git repository." + git clone $repo $directory + cd $directory + fi + + echo "[$directory] Installing Yarn dependencies." + yarn --silent + cd .. + + echo +} + +update "git@git.holllo.cc:Bauke/userscripts.git" "userscripts" +update "git@git.holllo.cc:Bauke/userstyles.git" "userstyles" + +echo "All done!"