From 59c6a6aeb0bfd8e488fa0975af23f1219e41adde Mon Sep 17 00:00:00 2001 From: legendecas Date: Sat, 21 Nov 2020 03:43:56 +0800 Subject: [PATCH] fix: git-clang-format doesn't recognize no changes requested on given files (#835) --- package.json | 2 +- tools/README.md | 8 +++++++- {scripts => tools}/clang-format.js | 3 ++- 3 files changed, 10 insertions(+), 3 deletions(-) rename {scripts => tools}/clang-format.js (92%) diff --git a/package.json b/package.json index 2d25d0aaa..85d6ea2d1 100644 --- a/package.json +++ b/package.json @@ -303,7 +303,7 @@ "predev:incremental": "node-gyp configure build -C test --debug", "dev:incremental": "node test", "doc": "doxygen doc/Doxyfile", - "lint": "node scripts/clang-format.js", + "lint": "node tools/clang-format.js", "lint:fix": "git-clang-format" }, "pre-commit": "lint", diff --git a/tools/README.md b/tools/README.md index 8d110609c..a1024d586 100644 --- a/tools/README.md +++ b/tools/README.md @@ -1,4 +1,10 @@ -# Migration Script +# Tools + +## clang-format + +The clang-format checking tools is designed to check changed lines of code compared to given git-refs. + +## Migration Script The migration tool is designed to reduce repetitive work in the migration process. However, the script is not aiming to convert every thing for you. There are usually some small fixes and major reconstruction required. diff --git a/scripts/clang-format.js b/tools/clang-format.js similarity index 92% rename from scripts/clang-format.js rename to tools/clang-format.js index b44d47674..3a2ba4a2f 100644 --- a/scripts/clang-format.js +++ b/tools/clang-format.js @@ -27,7 +27,8 @@ function main(args) { } const clangFormatOutput = result.stdout.trim(); - if (clangFormatOutput !== ('no modified files to format') && + if (clangFormatOutput !== '' && + clangFormatOutput !== ('no modified files to format') && clangFormatOutput !== ('clang-format did not modify any files')) { console.error(clangFormatOutput); const fixCmd = '"npm run lint:fix"';