mirror of
https://github.com/hcengineering/platform.git
synced 2026-09-12 04:37:44 +02:00
Fast formatting (#2658)
Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
@@ -154,7 +154,7 @@ jobs:
|
||||
- name: Install...
|
||||
run: node common/scripts/install-run-rush.js install
|
||||
- name: Formatting...
|
||||
run: node common/scripts/install-run-rush.js format
|
||||
run: node common/scripts/install-run-rush.js fast-format
|
||||
- name: Check files formatting
|
||||
run: |
|
||||
echo '================================================================'
|
||||
|
||||
@@ -316,6 +316,14 @@
|
||||
"description": "Clean package-deps-*.json files",
|
||||
"safeForSimultaneousRushProcesses": true,
|
||||
"shellCommand": "find .|grep .rush/temp/package-deps_ | xargs rm"
|
||||
},
|
||||
{
|
||||
"commandKind": "global",
|
||||
"name": "fast-format",
|
||||
"summary": "Format changed projects",
|
||||
"description": "Format and autofix linting issues in changed projects",
|
||||
"safeForSimultaneousRushProcesses": true,
|
||||
"shellCommand": "./common/scripts/each-diff.sh rushx format"
|
||||
}
|
||||
],
|
||||
|
||||
|
||||
Executable
+44
@@ -0,0 +1,44 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
FILES=$(git diff origin/main --name-only --diff-filter=ACMR | sed 's| |\\ |g')
|
||||
[ -z "$FILES" ] && exit 0
|
||||
|
||||
roots=$(rush list -p --json | grep "path" | cut -f 2 -d ':' | cut -f 2 -d '"')
|
||||
|
||||
declare -a changed_roots
|
||||
|
||||
pushd () {
|
||||
command pushd "$@" > /dev/null
|
||||
}
|
||||
|
||||
popd () {
|
||||
command popd "$@" > /dev/null
|
||||
}
|
||||
|
||||
if [ -n "$FILES" ]; then
|
||||
for file in $FILES; do
|
||||
# Match file to root
|
||||
for r in $roots; do
|
||||
if [[ "$file" == ${r}* ]]; then
|
||||
echo -e "${file}"
|
||||
if [[ ! " ${changed_roots[@]} " =~ " ${r} " ]]; then
|
||||
changed_roots+=("$r")
|
||||
fi
|
||||
fi
|
||||
done
|
||||
done
|
||||
for value in "${changed_roots[@]}"; do
|
||||
echo -e "\033[0;34mProcessing \033[0;31m${value}\033[0m"
|
||||
exec 3>&1
|
||||
exec 1> >(paste /dev/null -)
|
||||
pushd $value > /dev/null
|
||||
$@
|
||||
retVal=$?
|
||||
if [ $retVal -ne 0 ]; then
|
||||
echo "Error"
|
||||
exit 1
|
||||
fi
|
||||
popd > /dev/null
|
||||
exec 1>&3 3>&-
|
||||
done
|
||||
fi
|
||||
Reference in New Issue
Block a user