Last active
April 20, 2022 01:53
-
-
Save nmccready/26bd956b417aade97808453d7b95c6c7 to your computer and use it in GitHub Desktop.
parse args and forward
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
# !/usr/bin/env bash | |
ROOT_DIR=$(pwd) | |
helpMenu() { | |
echo ' | |
-i|--install) install all dependencies | |
-in|--install-node) install node dependencies | |
-if|--install-flutter) install flutter dependencies | |
-h|--help) this menu | |
' | |
} | |
usage_error () { echo >&2 "$(basename $0): $1"; exit 2; } | |
install_node() { | |
for i in $(find ./packages -name "package.json" | grep -v node_modules); do | |
local loc=$(echo "$i" | sed 's/\/package.json//g') | |
cd "$loc" | |
echo | |
echo "install $loc" | |
npm install | |
echo "done install $loc" | |
cd "$ROOT_DIR" | |
done | |
echo "== node dependencies done ==" | |
} | |
# Because melos is not ready (hangs and swallows output) | |
# see https://github.com/invertase/melos/issues/135 | |
install_flutter(){ | |
for i in $(find ./packages -name "pubspec.yaml"); do | |
local loc=$(echo "$i" | sed 's/\/pubspec.yaml//g') | |
cd "$loc" | |
flutter pub get | |
cd "$ROOT_DIR" | |
done | |
echo "== flutter dependencies done ==" | |
} | |
install() { | |
install_flutter | |
install_node | |
} | |
while [[ "$#" > 0 ]]; do case $1 in | |
-i|--install) install;; | |
-in|--install-node) install_node;; | |
-if|--install-flutter) install_flutter;; | |
-h|--help) helpMenu;; | |
# -r|--repository-name) shift; DOCKER_REPO=$1;; | |
-*) usage_error "unknown option: '$1'";; | |
*) usage_error "this should NEVER happen ($1)";; | |
esac; shift; done |
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
while [[ "$#" > 0 ]]; do case $1 in | |
-j|--package-json) shift; PACKAGE_JSON_LOC=$1;; | |
-r|--repository-name) shift; DOCKER_REPO=$1;; | |
*) args[${#args[@]}]=$1;; | |
esac; shift; done | |
someFunction ${args[@]} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment