From 6f3a67d10e3d2f6a9d15982d072c264483f96e6a Mon Sep 17 00:00:00 2001 From: Rafal Walczyna Date: Mon, 22 Jul 2019 12:55:38 +0200 Subject: [PATCH] [Project][code_formatter] Fix JS files formatting error Due to a bug, js files were not formatting. Tested manually - js formatting works. Change-Id: I5a4e2f2dc05241e15c85815f8380563303fa7ed1 Signed-off-by: Rafal Walczyna --- tools/codestyle/c++_clang_formatter.sh | 15 +++++++-------- tools/codestyle/code_formatter.sh | 2 +- tools/codestyle/js_eslint_formatter.sh | 6 ++---- 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/tools/codestyle/c++_clang_formatter.sh b/tools/codestyle/c++_clang_formatter.sh index 7e0b32e..25f963a 100755 --- a/tools/codestyle/c++_clang_formatter.sh +++ b/tools/codestyle/c++_clang_formatter.sh @@ -38,14 +38,13 @@ formatC++() { } checkUpdatedFiles() { - files="$(git diff-index -z --name-only --diff-filter=AM HEAD --)" - while IFS= read -r -d '' f; do - if [ "${f: -3}" == ".cc" ] || [ "${f: -4}" == ".cpp" ] || [ "${f: -2}" == ".h" ] || \ - [ "${f: -4}" == ".hpp" ]; then - printf '.' - clang-format -i -style="$config" "$f"; - fi - done <<< "$files" + while IFS= read -r -d '' f; do + if [ "${f: -3}" == ".cc" ] || [ "${f: -4}" == ".cpp" ] || [ "${f: -2}" == ".h" ] || \ + [ "${f: -4}" == ".hpp" ]; then + printf '.' + clang-format -i -style="$config" "$f"; + fi + done < <(git diff-index -z --name-only --diff-filter=AM HEAD --) } printf "C/C++ reformatting: "; diff --git a/tools/codestyle/code_formatter.sh b/tools/codestyle/code_formatter.sh index ef553dd..33e1968 100755 --- a/tools/codestyle/code_formatter.sh +++ b/tools/codestyle/code_formatter.sh @@ -53,7 +53,7 @@ formatJsAndC++() { backupUpdatedFiles() { files_to_update="$(git diff-index -z --name-only --diff-filter=AM HEAD --)"; if [[ "$files_to_update" == "" ]]; then - echo "There are no updated files to dormat"; + echo "There are no updated files to format"; exit; fi time_stamp=$(date +%Y-%m-%d-%T); diff --git a/tools/codestyle/js_eslint_formatter.sh b/tools/codestyle/js_eslint_formatter.sh index 2b23fb9..2af6757 100755 --- a/tools/codestyle/js_eslint_formatter.sh +++ b/tools/codestyle/js_eslint_formatter.sh @@ -35,19 +35,17 @@ formatJSFile() { } formatJSPath() { - js_files="$(find -- "$1" -type f -name "*.js" -print0)" while IFS= read -r -d '' f; do formatJSFile "$f"; - done <<< "$js_files" + done < <(find -- "$1" -type f -name "*.js" -print0) } checkUpdatedFiles() { - files="$(git diff-index -z --name-only --diff-filter=AM HEAD --)" while IFS= read -r -d '' f; do if [[ "${f: -3}" == ".js" ]]; then formatJSFile "$f"; fi - done <<< "$files" + done < <(git diff-index -z --name-only --diff-filter=AM HEAD --) } printf "JS reformatting: "; -- 2.7.4