Created
January 7, 2025 13:29
Revisions
-
akarca created this gist
Jan 7, 2025 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,34 @@ #!/usr/bin/env bash if [ -z "$1" ] then echo "No argument supplied. Usage: add-requirement Django" fi FILE="requirements.txt" if [ -f $FILE ]; then echo "Add requirement $1 to $FILE" else echo "File $FILE does not exist." exit 1 fi pip install $1 RESULT=$(pip freeze | grep $1) echo $RESULT if [[ $RESULT == $1==* ]] then RESULT2=$(cat $FILE | grep $1) if [[ $RESULT2 == $1==* ]] then echo "Already added $1 to $FILE" else echo $RESULT >> $FILE echo "Added $RESULT to $FILE" fi else echo "Can't add $1 to $FILE. pip package name is not equals to $1"; fi