0
Files
android_webview
apps
ash
base
build
build_overrides
buildtools
cc
chrome
chromecast
chromeos
clank
codelabs
components
content
crypto
dbus
device
docs
extensions
fuchsia_web
gin
google_apis
gpu
headless
infra
internal
ios
ios_internal
ipc
media
mojo
native_client
native_client_sdk
net
pdf
ppapi
printing
remoting
rlz
sandbox
services
signing_keys
skia
sql
storage
styleguide
testing
third_party
tools
accessibility
aggregation_service
android
binary_size
bisect
bisect_repackage
captured_sites
cast3p
cfi
check_ecs_deps
checkbins
checklicenses
checkperms
checkteamtags
chrome_extensions
chromeos
clang
code_coverage
codeql
compile_test
cr
crates
crbug
cros
cygprofile
determinism
diagnosis
disable_tests
dromaeo_benchmark_runner
dump_process_memory
emacs
find_runtime_symbols
flags
flakiness
fuchsia
gdb
generate_library_loader
generate_shim_headers
generate_stubs
get_asan_chrome
get_swarming_logs
git
gn
grd
grit
gritsettings
idl_parser
imagediff
infra
interactive_ui_tests
ipc_fuzzer
json_comment_eater
json_data_generator
json_schema_compiler
json_to_struct
l10n
licenses
linux
lldb
mac
mb
md_browser
media_engagement_preload
memory
metrics
msan
nix
nocompile
oobe
origin_trials
page_cycler
perf
perfbot-analysis
pgo
pixel_test
polymer
privacy_budget
profiling
protoc_wrapper
python
real_world_impact
resources
rust
search_engine_choice
security
site_compare
strict_enum_value_checker
style_variable_generator
sublime
symsrc
traceline
tracing
traffic_annotation
translation
typescript
ubsan
usb_gadget
utr
v8_context_snapshot
valgrind
variations
vim
visual_debugger
vscode
warning_analysis
web_bluetooth
web_dev_style
whats_new
win
.gitignore
.style.yapf
DEPS
DIR_METADATA
OWNERS
PRESUBMIT.py
README.md
add_header.py
add_header_test.py
apply_cpplint_header_guard.py
auto-nav.py
autotest.py
bash-completion
bisect-builds.py
bisect_test.py
boilerplate.py
buildstate.bat
buildstate.py
check_git_config.py
check_grd_for_unused_strings.py
clang-format-js
diagnose-me.py
download_optimization_profile.py
hresult_to_enum.py
include_tracer.py
ipc_messages_log.py
make_gtest_filter.py
make_gtest_filter_test.py
mojo_messages_log.py
multi_process_rss.py
omahaproxy.py
perry.py
remove_stale_files.py
remove_stale_pyc_files.py
roll_webgl_conformance.py
run-swarmed.py
sample_clang_tidy_results.py
sort_sources.py
uberblame.py
unused-symbols-report.py
update_pgo_profiles.py
yes_no.py
ui
url
v8
webkit
.clang-format
.clang-tidy
.clangd
.git-blame-ignore-revs
.gitallowed
.gitattributes
.gitignore
.gitmodules
.gn
.mailmap
.rustfmt.toml
.vpython3
.yapfignore
ATL_OWNERS
AUTHORS
BUILD.gn
CODE_OF_CONDUCT.md
CPPLINT.cfg
CRYPTO_OWNERS
DEPS
DIR_METADATA
LICENSE
LICENSE.chromium_os
OWNERS
PRESUBMIT.py
PRESUBMIT_test.py
PRESUBMIT_test_mocks.py
README.md
WATCHLISTS
codereview.settings
src/tools/clang-format-js
Thiago Perrotta 89089d31e3 clang-format: support -h/--help to invoke usage
Bug: None
Change-Id: Ida7703ce6a0a8f5db13b5676f8f2a7b46fb85d61
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4035692
Auto-Submit: Thiago Perrotta <tperrotta@chromium.org>
Commit-Queue: Dirk Pranke <dpranke@google.com>
Reviewed-by: Dirk Pranke <dpranke@google.com>
Cr-Commit-Position: refs/heads/main@{#1073546}
2022-11-18 21:05:38 +00:00

41 lines
1.1 KiB
Bash
Executable File

#!/bin/bash
# Copyright 2016 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
if [[ -z "$@" || "$1" == "-h" || "$1" == "--help" ]]; then
echo >&2 "Usage: `basename $0` <paths_to_clang_format...>"
exit 1
fi
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
fi
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
elif [[ "${dir}" == "/" ]]; then
echo >&2 "No .clang-format file found. Make one at or above ${arg}"
exit 1
fi
done
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