| 1 |
#!/usr/bin/env bash |
| 2 |
# |
| 3 |
# Copyright 2024 The Fuchsia Authors |
| 4 |
# |
| 5 |
# Licensed under a BSD-style license <LICENSE-BSD>, Apache License, Version 2.0 |
| 6 |
# <LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0>, or the MIT |
| 7 |
# license <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your option. |
| 8 |
# This file may not be copied, modified, or distributed except according to |
| 9 |
# those terms. |
| 10 |
|
| 11 |
set -eo pipefail |
| 12 |
cd "$(dirname "$0")/.." |
| 13 |
|
| 14 |
if [[ "$1" == "--fix" ]]; then |
| 15 |
FMT_FLAGS="" |
| 16 |
else |
| 17 |
FMT_FLAGS="--check" |
| 18 |
fi |
| 19 |
|
| 20 |
find . -iname '*.rs' -type f \ |
| 21 |
-not -path './target/*' \ |
| 22 |
-not -iname '*.expected.rs' \ |
| 23 |
-not -path './vendor/*' \ |
| 24 |
-print0 | xargs -0 --no-run-if-empty ./cargo.sh +nightly fmt $FMT_FLAGS -- >&2 |