| Index: tools/clang-format-js
|
| diff --git a/tools/clang-format-js b/tools/clang-format-js
|
| index 4b04d8dc79809dc5d5b1404edc5c2fa5ca048c9a..b8a92b53a255a3e7457f29970f99a5f7973c425a 100755
|
| --- a/tools/clang-format-js
|
| +++ b/tools/clang-format-js
|
| @@ -4,30 +4,37 @@
|
| # found in the LICENSE file.
|
|
|
| if [[ -z "${@}" ]]; then
|
| - echo >&2 "Usage: `basename $0` <paths_to_clang_format...>";
|
| - exit 1;
|
| + echo >&2 "Usage: `basename $0` <paths_to_clang_format...>"
|
| + exit 1
|
| fi
|
|
|
| -which clang-format >/dev/null 2>&1;
|
| +which clang-format >/dev/null 2>&1
|
| if [[ $? -ne 0 ]]; then
|
| - echo >&2 "Sorry, but you need \`clang-format\` on your \$PATH to run this script";
|
| - exit 1;
|
| + echo >&2 "Sorry, but you need \`clang-format\` on your \$PATH to run this script"
|
| + exit 1
|
| fi
|
|
|
| -for arg in "${@}"; do
|
| +for arg in ${@}; do
|
| + echo "Processing ${arg}"
|
| +
|
| dir=`readlink -f "${arg}"`
|
| if [[ -d "${dir}" ]]; then
|
| dir="${dir}/stripped-by-dirname-on-next-line"
|
| fi
|
| while dir=`dirname ${dir}`; do
|
| if [[ -f "${dir}/.clang-format" ]]; then
|
| - echo "Using style from: ${dir}/.clang-format";
|
| - break;
|
| + echo "Using style from: ${dir}/.clang-format"
|
| + break
|
| elif [[ "${dir}" == "/" ]]; then
|
| - echo >&2 "No .clang-format file found. Make one at or above ${arg}";
|
| - exit 1;
|
| + echo >&2 "No .clang-format file found. Make one at or above ${arg}"
|
| + exit 1
|
| fi
|
| done
|
| -done
|
|
|
| -find "${@}" -type f -iname '*.js' | xargs clang-format -i -style=file;
|
| + js_files=$(git ls-tree -r --name-only HEAD -- "${arg}" | grep '\.js$')
|
| +
|
| + for js_file in ${js_files}; do
|
| + echo "Formatting ${js_file}"
|
| + clang-format -i -style=file "$js_file"
|
| + done
|
| +done
|
|
|