Skip to content

Commit

Permalink
Enable *.js reformatting in format-code.sh
Browse files Browse the repository at this point in the history
Change the format-code.shdeveloper script to also automatically reformat
any change JavaScript file.

In the past, all JS code written in this repository was formatted
manually. The plan is to switch to the clang-based automatic formatting,
and the first step on this route is to apply it to every changed file.

This contributes to the refactoring effort tracked by #264.
  • Loading branch information
emaxx-google committed Jul 26, 2021
1 parent 39e37b7 commit d7a9e41
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions format-code.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# This script formats the modified C++ files via clang-format according to the
# Chromium C++ Style Guide.
# This script formats the modified C++/JS files via clang-format according to
# the Chromium Style Guides.
# Only files that are known to Git and belong to the diff of the "master" branch
# are considered.
#
# Note: Sorting of #include's is currently disabled, since the standard
# Note: Sorting of C/C++ #include's is currently disabled, since the standard
# algorithm reorders them incorrectly (e.g., it puts includes within our project
# into the same group as C system headers).

Expand All @@ -31,7 +31,7 @@ cd $(dirname $(realpath ${0}))
# Find all relevant touched files. Bail out if nothing is found.
# Note: "d" in --diff-filter means excluding deleted files - otherwise
# clang-format fails on these non-existing files.
FILES=$(git diff --name-only --diff-filter=d master -- "*.cc" "*.h")
FILES=$(git diff --name-only --diff-filter=d master -- "*.cc" "*.h" "*.js")
[ "${FILES}" ] || exit 0

# Run clang-format on every found file.
Expand Down

0 comments on commit d7a9e41

Please sign in to comment.