-
-
Notifications
You must be signed in to change notification settings - Fork 660
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d45a5a1
commit e627ae3
Showing
2 changed files
with
12 additions
and
20 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,13 @@ | ||
#!/usr/bin/env bash | ||
SCRIPT_DIR=$( dirname -- "$0" ) | ||
CURRENT_BRANCH=$(git branch --show-current) | ||
MAIN_BRANCH_DIR=${1:-../main} | ||
set -e | ||
FOLDER="${1:-.}" | ||
|
||
# update strictNullChecks in main and current branch | ||
sed -i 's/\/\/\s*"strictNullChecks":\s*true,/"strictNullChecks": true,/' "${MAIN_BRANCH_DIR}/tsconfig.json" | ||
sed -i 's/\/\/\s*"strictNullChecks":\s*true,/"strictNullChecks": true,/' "${SCRIPT_DIR}/../tsconfig.json" | ||
cd "${FOLDER}" | ||
|
||
# count errors | ||
MAIN_ERRORS=$(cd "${MAIN_BRANCH}"; yarn 2> /dev/null | grep "Found [0-9]* errors" | sed 's/Found \(.*\) errors in .* files./\1/') | ||
BRANCH_ERRORS=$(yarn 2> /dev/null | grep "Found [0-9]* errors" | sed 's/Found \(.*\) errors in .* files./\1/') | ||
# update strictNullChecks | ||
sed -i 's/\/\/\s*"strictNullChecks":\s*true,/"strictNullChecks": true,/' "./tsconfig.json" | ||
|
||
# reset tsconfig changes | ||
git checkout -- "${SCRIPT_DIR}/../tsconfig.json" | ||
$(cd "${MAIN_BRANCH}"; git checkout -- tsconfig.json) | ||
# count errors | ||
ERRORS=$(yarn 2> /dev/null | grep "Found [0-9]* errors" | sed 's/Found \(.*\) errors in .* files./\1/') | ||
|
||
if [ $BRANCH_ERRORS -gt $MAIN_ERRORS ]; then | ||
echo "Null check errors in ${CURRENT_BRANCH} are higher than in ${MAIN_BRANCH}: ${BRANCH_ERRORS} vs ${MAIN_ERRORS}. Please fix them before merging." | ||
exit 1 | ||
else | ||
echo "Branch null check errors: ${BRANCH_ERRORS} vs ${MAIN_BRANCH}: ${MAIN_ERRORS} - You're good to go!" | ||
exit 0 | ||
fi | ||
echo ${ERRORS:-0} |