Last active
July 9, 2023 21:49
-
-
Save vcanales/e8f34eeb0fb4f1e23e0aaba148c1c024 to your computer and use it in GitHub Desktop.
Common sequence of commands run when developing for Gutenberg
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Bash script that runs nvm and npm to update the gutenberg plugin | |
# and then runs the build script to build the plugin | |
# Usage: ./updateGutenberg.sh [--pull] [--no-build] | |
# --no-pull: pull from git before running npm | |
# --no-build: don't run the build script after running npm | |
PULL="false" | |
BUILD="true" | |
# parse command line options including whole-word options | |
for i in "$@" | |
do | |
case $i in | |
--pull) | |
PULL="true" | |
shift # past argument=value | |
;; | |
--no-build) | |
BUILD="false" | |
shift # past argument=value | |
;; | |
*) | |
echo "Unknown option: $i" | |
# unknown option | |
;; | |
esac | |
done | |
# pull from git unless --no-pull flag is set | |
if [ $PULL == true ]; then | |
git pull | |
fi | |
# load nvm | |
source ~/.nvm/nvm.sh | |
nvm use | |
# run npm commands | |
npm install | |
# run build script unless --no-build flag is set | |
if [ $BUILD == true ]; then | |
npm run build | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment