From 557708a9eb5bf255f74cdc7d39e567d1708caaf6 Mon Sep 17 00:00:00 2001 From: Guilherme Gazzo Date: Tue, 6 Dec 2022 15:10:14 -0300 Subject: [PATCH] Chore: Update fuselage.sh script --- fuselage.sh | 69 ++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 60 insertions(+), 9 deletions(-) diff --git a/fuselage.sh b/fuselage.sh index 44a1f6919ed..ff9c110b67b 100755 --- a/fuselage.sh +++ b/fuselage.sh @@ -1,6 +1,39 @@ #!/bin/bash -if [[ $1 != "undo" ]]; then +if [[ $1 == "--help" || $1 == "-h" ]]; then + echo "Usage: fuselage.sh -a link|undo -p fuselage;fuselage-icons" + exit 1 +fi + +while getopts ":a:p:" opt; do + case $opt in + a) action="$OPTARG" + ;; + p) packages="$OPTARG" + ;; + \?) echo "Invalid option -$OPTARG" >&2 + exit 1 + ;; + esac + + case $OPTARG in + -*) echo "Option $opt needs a valid argument" + exit 1 + ;; + esac +done + +echo "action: $action" + +action="${action:-link}" +packages="${packages:-fuselage}" + +if [[ $action != "link" && $action != "undo" ]]; then + echo "Invalid action" + exit 1 +fi + +if [[ $action != "undo" ]]; then echo "linking local project" else echo "unlinking local project" @@ -8,21 +41,39 @@ fi cd ./node_modules/@rocket.chat -rm -rf fuselage -if [[ $1 != "undo" ]]; then - ln -s ../../../fuselage/packages/fuselage fuselage -fi +for i in $(echo $packages | tr ";" "\n") + do + rm -rf $i + if [[ $action != "undo" ]]; then + ln -s "../../../fuselage/packages/$i" $i + echo "root $i" + fi + done + cd ../.. cd ./apps/meteor/node_modules/@rocket.chat -rm -rf fuselage -if [[ $1 != "undo" ]]; then + +for i in $(echo $packages | tr ";" "\n") + do + rm -rf $i + if [[ $action != "undo" ]]; then + rm -rf $i + fi + done + + +if [[ $action != "undo" ]]; then echo "linking local project" - ln -s ../../../../../fuselage/packages/fuselage fuselage + for i in $(echo $packages | tr ";" "\n") + do + ln -s "../../../../../fuselage/packages/$i" $i + echo "apps/meteor $i" + done fi cd ../../../../ -if [[ $1 == "undo" ]]; then +if [[ $action == "undo" ]]; then yarn fi