#!/bin/bash


if [ ! -d .git ];
then
	echo "in a git directory plz"
	exit 0
fi

IISPORTHTTPS='44356'

REPO="$(pwd | xargs cygpath --windows | sed 's/\\/\\\\/g')"

echo "let change the .config for IISEXPRESS"

for FILE in $(find -iname "environment.ts" -o -iname "angular.json" )
do
	if grep -qi "apiUrl" "$FILE"
	then
		printf "$FILE";
		printf "."

		git update-index -q --assume-unchanged $FILE
		printf "."

		sed -i "s/https:\/\/localhost:44355/https:\/\/localhost:$IISPORTHTTPS/IM" $FILE;
		printf "."

	fi

	if grep -qi "@angular" "$FILE"
	then
		printf "$FILE";
		printf "."

		git update-index -q --assume-unchanged $FILE
		printf "."

		sed -i 's/"port": [0-9]*/\01/IM' $FILE;
		printf "."

	fi
done

echo "done"

