summaryrefslogtreecommitdiffstats
path: root/format-code.sh
blob: afcf8c486232c44d2a092634ec43fb87238294b9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/bin/bash

# This script reformats source files using the clang-format utility.
#
# Files are changed in-place, so make sure you don't have anything open in an
# editor, and you may want to commit before formatting in case of awryness.
#
# This must be run on a clean repository to succeed

DIR=$(pwd)
cd ${DIR}

set -e

echo "Formatting code under $DIR/"

# Only validate certain areas of the code base for
# formatting due to some imported code in webui

if [ -f ".clang-format" ]; then
    clang-format-6.0 -i `git ls-files '*.js'`
    git --no-pager diff --exit-code
fi
OpenPOWER on IntegriCloud