| OLD | NEW |
| 1 #!/bin/bash | 1 #!/bin/bash |
| 2 set -e | 2 set -e |
| 3 | 3 |
| 4 # Switch to the root directory of dev_compiler | 4 # Switch to the root directory of dev_compiler |
| 5 cd $( dirname "${BASH_SOURCE[0]}" )/.. | 5 cd $( dirname "${BASH_SOURCE[0]}" )/.. |
| 6 | 6 |
| 7 # Run formatter in rewrite mode on all files that are part of the project. | 7 # Run formatter in rewrite mode on all files that are part of the project. |
| 8 # This checks that all files are commited first to git, so no state is lost. | 8 # This checks that all files are commited first to git, so no state is lost. |
| 9 # The formatter ignores: | 9 # The formatter ignores: |
| 10 # * local files that have never been added to git, | 10 # * local files that have never been added to git, |
| 11 # * subdirectories of test/ and tool/, unless explicitly added. Those dirs | 11 # * subdirectories of test/ and tool/, unless explicitly added. Those dirs |
| 12 # contain a lot of generated or external source we should not reformat. | 12 # contain a lot of generated or external source we should not reformat. |
| 13 (files=`git ls-files 'bin/*.dart' 'lib/*.dart' test/*.dart test/checker/*.dart \ | 13 (files=`git ls-files 'bin/*.dart' 'lib/*.dart' test/*.dart test/checker/*.dart \ |
| 14 tool/*.dart | grep -v lib/src/js_ast/`; git status -s $files | grep -q . \ | 14 tool/*.dart | grep -v lib/src/js_ast/`; git status -s $files | grep -q . \ |
| 15 && echo "Did not run the formatter, please commit edited files first." \ | 15 && echo "Did not run the formatter, please commit edited files first." \ |
| 16 || (echo "Running dart formatter" ; pub run dart_style:format -w $files)) | 16 || (echo "Running dart formatter" ; \ |
| 17 dart ../../third_party/pkg_tested/dart_style/bin/format.dart -w $files)) |
| OLD | NEW |