Skip to content

Instantly share code, notes, and snippets.

@vcanales
Last active July 9, 2023 21:49
Show Gist options
  • Save vcanales/e8f34eeb0fb4f1e23e0aaba148c1c024 to your computer and use it in GitHub Desktop.
Save vcanales/e8f34eeb0fb4f1e23e0aaba148c1c024 to your computer and use it in GitHub Desktop.
Common sequence of commands run when developing for Gutenberg
#!/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