diff options
author | Joyee Cheung <joyeec9h3@gmail.com> | 2018-07-13 20:19:31 +0800 |
---|---|---|
committer | Joyee Cheung <joyeec9h3@gmail.com> | 2018-08-03 19:40:23 +0800 |
commit | 0da144f4d48d7a423b8f61cd178bb41346083107 (patch) | |
tree | 0bdf31c067fc7991fea2ebef0831930b55b0069c /tools | |
parent | 049c0464ce40cef17e8476b3e6b909bb10de469b (diff) | |
download | node-new-0da144f4d48d7a423b8f61cd178bb41346083107.tar.gz |
tools: add `make format-cpp` to run clang-format on C++ diffs
This patch adds a `make format-cpp` shortcut to the Makefile
that runs clang-format on the C++ diffs, and a
`make format-cpp-build` to install clang-format from
npm.
To format staged changes:
```
$ make format-cpp
```
To format HEAD~1...HEAD (latest commit):
```
$ CLANG_FORMAT_START=`git rev-parse HEAD~1` make format-cpp
```
To format diff between master and current branch head (master...HEAD):
```
$ CLANG_FORMAT_START=master make format-cpp
```
Most of the .clang-format file comes from running
```
$ clang-format --dump-config --style=Google
```
with clang-format built with llvm/trunk 328768 (npm version 1.2.3)
The clang-format version is fixed because different version of
clang-format may format the files differently.
PR-URL: https://github.com/nodejs/node/pull/21997
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Michaƫl Zasso <targos@protonmail.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/clang-format/package.json | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/tools/clang-format/package.json b/tools/clang-format/package.json new file mode 100644 index 0000000000..8432296ed6 --- /dev/null +++ b/tools/clang-format/package.json @@ -0,0 +1,9 @@ +{ + "name": "node-core-clang-format", + "version": "1.0.0", + "description": "Formatting C++ files for Node.js core", + "license": "MIT", + "dependencies": { + "clang-format": "1.2.3" + } +} |