clang-format-node 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +364 -0
- package/build/bin/darwin-arm64/clang-format +0 -0
- package/build/bin/darwin-x64/clang-format +0 -0
- package/build/bin/linux-arm/clang-format +0 -0
- package/build/bin/linux-arm64/clang-format +0 -0
- package/build/bin/linux-ppc64/clang-format +0 -0
- package/build/bin/linux-s390x/clang-format +0 -0
- package/build/bin/linux-x64/clang-format +0 -0
- package/build/bin/win32-x64/clang-format.exe +0 -0
- package/build/getClangFormatPath.js +1 -0
- package/build/index.js +2 -0
- package/package.json +84 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 루밀LuMir(lumirlumir)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,364 @@
|
|
|
1
|
+
# clang-format-node
|
|
2
|
+
|
|
3
|
+
[](https://github.com/lumirlumir/npm-clang-format-node/actions/workflows/lint.yml)
|
|
4
|
+
[](https://github.com/lumirlumir/npm-clang-format-node/actions/workflows/test.yml)
|
|
5
|
+
[](https://codecov.io/gh/lumirlumir/npm-clang-format-node)
|
|
6
|
+
[](https://www.npmjs.com/package/clang-format-node)
|
|
7
|
+
&color=violet)
|
|
8
|
+
|
|
9
|
+
Node repackaging(wrapping) of the `clang-format` native binary inspired by ['angular/clang-format'](https://github.com/angular/clang-format).🐉
|
|
10
|
+
|
|
11
|
+
This package intends to release a new npm package for every **latest** release of the `clang-format`. It **checks** for the latest LLVM release every week, builds `clang-format` using its own pipeline, and makes a **pull request**. All processes are run automatically. If you are interested in build process, take a look at [`.github/workflows/llvm-build-bump-pr.yml`](/.github/workflows/llvm-build-bump-pr.yml)
|
|
12
|
+
|
|
13
|
+
## Why I started this project
|
|
14
|
+
|
|
15
|
+
['angular/clang-format'](https://github.com/angular/clang-format) is no longer maintained. (See [#79](https://github.com/angular/clang-format/issues/79) [#82](https://github.com/angular/clang-format/issues/82) [#83](https://github.com/angular/clang-format/pull/83)) Nevertheless, new versions of `clang-format` continue to be released. Bugs are fixed, and new features are added. However, using `clang-format` directly in a Node.js environment without any support can be somewhat cumbersome. So I decided to make a **new**, **maintained** one.
|
|
16
|
+
|
|
17
|
+
Note that some feautures from 'angular/clang-format' are not included in this package. Specifically `check-clang-format` and `git-clang-format` are not used. There are a few reasons for this. Both commands **rely on Python**, so if you haven't installed Python, they cannot be executed. Many people would prefer if this package worked without dependencies beyond Node.js. **So, this package relies only on Node.js.** See the [Migration](#migration-from-angularclang-format) for alternative methods to `check-clang-format` and `git-clang-format`.
|
|
18
|
+
|
|
19
|
+
## Supported OS platforms and architectures
|
|
20
|
+
|
|
21
|
+
It supports **ALL** [**Tier1**](https://github.com/nodejs/node/blob/main/BUILDING.md#strategy) and some [**Tier2**](https://github.com/nodejs/node/blob/main/BUILDING.md#strategy) platforms of Node.js. *Note that the functionality cannot be guaranteed on platforms which is not mentioned below*.
|
|
22
|
+
|
|
23
|
+
(To see the full list of platforms supported by Node.js, click [here](<https://github.com/nodejs/node/blob/main/BUILDING.md#platform-list>).)
|
|
24
|
+
|
|
25
|
+
<br> | Operating System | Architectures | Versions | Support Type |
|
|
26
|
+
---- | ---------------- | ---------------- | --------------------------------- | ------------ |
|
|
27
|
+
1 | macOS | arm64 | >= 11.0 | Tier 1 |
|
|
28
|
+
2 | macOS | x64 | >= 11.0 | Tier 1 |
|
|
29
|
+
3 | GNU/Linux | armv7 | kernel >= 4.18, glibc >= 2.28 | Tier 1 |
|
|
30
|
+
4 | GNU/Linux | arm64 | kernel >= 4.18, glibc >= 2.28 | Tier 1 |
|
|
31
|
+
5 | GNU/Linux | ppc64le >=power8 | kernel >= 4.18, glibc >= 2.28 | Tier 2 |
|
|
32
|
+
6 | GNU/Linux | s390x | kernel >= 4.18, glibc >= 2.28 | Tier 2 |
|
|
33
|
+
7 | GNU/Linux | x64 | kernel >= 4.18, glibc >= 2.28 | Tier 1 |
|
|
34
|
+
8 | Windows | x64 | >= Windows 10/Server 2016 | Tier 1 |
|
|
35
|
+
|
|
36
|
+
> [!TIP]
|
|
37
|
+
>
|
|
38
|
+
> 1. If your platform isn't yet supported, you can build the `clang-format` native binary from the latest upstream clang sources. Refer to [`docs/llvm-build-linux.sh`](/docs/llvm-build-linux.sh) and [`docs/llvm-build-linux-x64.yml`](/docs/llvm-build-linux-x64.yml) for the Linux build scripts for **Shell** and **GitHub Actions**, respectively.
|
|
39
|
+
>
|
|
40
|
+
> 1. Or you can download `clang-format` native binary from [LLVM release assets](https://github.com/llvm/llvm-project/releases) that match your operating system platform and architecture like the lists below.
|
|
41
|
+
>
|
|
42
|
+
> - `clang+llvm-18.1.7-aarch64-linux-gnu.tar.xz`
|
|
43
|
+
> - `clang+llvm-18.1.7-armv7a-linux-gnueabihf.tar.gz`
|
|
44
|
+
> - `clang+llvm-18.1.7-powerpc64-ibm-aix-7.2.tar.xz`
|
|
45
|
+
> - `clang+llvm-18.1.7-x86_64-pc-windows-msvc.tar.xz`
|
|
46
|
+
> - `and more...`
|
|
47
|
+
|
|
48
|
+
## Installation
|
|
49
|
+
|
|
50
|
+
### global
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
npm install -g clang-format-node
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
yarn global add clang-format-node
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### local(devDependencies)
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
npm install --save-dev clang-format-node
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
yarn add --dev clang-format-node
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Usages
|
|
71
|
+
|
|
72
|
+
If you want to learn more about `clang-format` itself, see the [`clang-format style options`](https://clang.llvm.org/docs/ClangFormatStyleOptions.html).
|
|
73
|
+
|
|
74
|
+
> [!TIP]
|
|
75
|
+
>
|
|
76
|
+
> `clang-format` can take multiple files as arguments.
|
|
77
|
+
>
|
|
78
|
+
> ```bash
|
|
79
|
+
> npx clang-format -n -Werror file1.cpp file2.cpp src/file3.cpp
|
|
80
|
+
> ```
|
|
81
|
+
|
|
82
|
+
### Basic
|
|
83
|
+
|
|
84
|
+
#### Global
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
clang-format [options] [@<file>] [<file> ...]
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
#### Local
|
|
91
|
+
|
|
92
|
+
Use `npx` to run a locally installed package.
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
npx clang-format [options] [@<file>] [<file> ...]
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
#### Frequently used commands
|
|
99
|
+
|
|
100
|
+
1. `--version`: Check the version of `clang-format`.
|
|
101
|
+
|
|
102
|
+
``` bash
|
|
103
|
+
npx clang-format --version
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
Output example
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
clang-format version 18.1.8 (https://github.com/llvm/llvm-project 3b5b5c1ec4a3095ab096dd780e84d7ab81f3d7ff)
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
- `https://github.com/llvm/llvm-project`: Git repository URL for the LLVM project, which includes Clang.
|
|
113
|
+
- `3b5b5c1ec4a3095ab096dd780e84d7ab81f3d7ff`: The commit hash of the Git repository where the source code for that version is stored. This hash allows you to precisely trace which source code version was used to generate `clang-format`.
|
|
114
|
+
|
|
115
|
+
1. `--help`: Help view additional options.
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
npx clang-format --help
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
1. `--dry-run` or `-n`: Makes an **WARNING** when `example.cpp` is not correctly formatted.
|
|
122
|
+
|
|
123
|
+
`--dry-run` and `-n` options are equivalent.
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
npx clang-format --dry-run example.cpp
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
```bash
|
|
130
|
+
npx clang-format -n example.cpp
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
1. `-Werror --dry-run` or `-Werror -n`: Makes an **ERROR** when `example.cpp` is not correctly formatted.
|
|
134
|
+
|
|
135
|
+
> Similar to `eslint` or `prettier --check` commands.
|
|
136
|
+
|
|
137
|
+
`--dry-run` and `-n` options are equivalent.
|
|
138
|
+
|
|
139
|
+
```bash
|
|
140
|
+
npx clang-format -Werror --dry-run example.cpp
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
npx clang-format -Werror -n example.cpp
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
1. `-i`: Automatically fix unformatted files.
|
|
148
|
+
|
|
149
|
+
> Similar to `eslint --fix` or `prettier --write` commands.
|
|
150
|
+
|
|
151
|
+
```bash
|
|
152
|
+
npx clang-format -i example.cpp
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
### Glob patterns
|
|
156
|
+
|
|
157
|
+
Unfortunately, there is no way to apply `clang-format` recursively. `*.cpp` will only match files in the current directory, not subdirectories. Even `**/*` doesn't work.
|
|
158
|
+
|
|
159
|
+
**So, you need to use the `find` command in Linux.** If you are a Windows user, use ***git bash***. then you can use the `find` command. The `find` command recursively searches through directories.
|
|
160
|
+
|
|
161
|
+
It is simple but can produce an error if the [**Argument list is too long**](https://stackoverflow.com/questions/11289551/argument-list-too-long-error-for-rm-cp-mv-commands). In that case, use `xargs`
|
|
162
|
+
|
|
163
|
+
#### Basic
|
|
164
|
+
|
|
165
|
+
To recursively search for all `.cpp` files in the current directory, use:
|
|
166
|
+
|
|
167
|
+
```bash
|
|
168
|
+
npx clang-format $(find . -name "*.cpp")
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
If the argument list is too long, use `xargs`. And if file names contain spaces or special characters, use `-print0` and `-0` options. `-print0` makes `find` output file names separated by null characters (`\0`), and `-0` tells `xargs` to correctly handle these null-separated file names.
|
|
172
|
+
|
|
173
|
+
```bash
|
|
174
|
+
find . -name "*.cpp" -print0 | xargs -0 npx clang-format
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
#### With regular expressions
|
|
178
|
+
|
|
179
|
+
To recursively search for all `.cpp` and `.h` files in the current directory using a regular expression, use:
|
|
180
|
+
|
|
181
|
+
```bash
|
|
182
|
+
npx clang-format $(find . -regex ".*\.\(cpp\|h\)")
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
#### With negation patterns
|
|
186
|
+
|
|
187
|
+
To exclude `excluded_file.cpp` from the `.cpp` files, use:
|
|
188
|
+
|
|
189
|
+
```bash
|
|
190
|
+
npx clang-format $(find . -name "*.cpp" ! -name "excluded_file.cpp")
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
### [`.clang-format-ignore`](https://clang.llvm.org/docs/ClangFormat.html#clang-format-ignore)
|
|
194
|
+
|
|
195
|
+
You can create `.clang-format-ignore` files to make `clang-format` ignore certain files. A `.clang-format-ignore` file consists of patterns of file path names. It has the following format:
|
|
196
|
+
|
|
197
|
+
- A blank line is skipped.
|
|
198
|
+
- Leading and trailing spaces of a line are trimmed.
|
|
199
|
+
- A line starting with a hash (`#`) is a comment.
|
|
200
|
+
- A non-comment line is a single pattern.
|
|
201
|
+
- The slash (`/`) is used as the directory separator.
|
|
202
|
+
- A pattern is relative to the directory of the `.clang-format-ignore` file (or the root directory if the pattern starts with a slash). Patterns containing drive names (e.g. `C:`) are not supported.
|
|
203
|
+
- Patterns follow the rules specified in [**POSIX 2.13.1, 2.13.2, and Rule 1 of 2.13.3.**](https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_13)
|
|
204
|
+
- A pattern is negated if it starts with a bang (`!`).
|
|
205
|
+
|
|
206
|
+
To match all files in a directory, use e.g. `foo/bar/*`. To match all files in the directory of the `.clang-format-ignore` file, use `*`. Multiple `.clang-format-ignore` files are supported similar to the `.clang-format` files, with a lower directory level file voiding the higher level ones.
|
|
207
|
+
|
|
208
|
+
### Use with `husky` and `lint-staged`
|
|
209
|
+
|
|
210
|
+
Ensuring that changes to your code are properly formatted is an important part of your development workflow. Use `husky` and `lint-staged` for your continuous integration process.
|
|
211
|
+
|
|
212
|
+
#### `husky` (v8.x)
|
|
213
|
+
|
|
214
|
+
```bash
|
|
215
|
+
# .husky/pre-commit
|
|
216
|
+
|
|
217
|
+
npx lint-staged
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
#### `lint-staged` (v15.x)
|
|
221
|
+
|
|
222
|
+
1. Check
|
|
223
|
+
|
|
224
|
+
```jsonc
|
|
225
|
+
/* package.json */
|
|
226
|
+
|
|
227
|
+
{
|
|
228
|
+
// ...
|
|
229
|
+
"lint-staged": {
|
|
230
|
+
"*.{c,cpp,h}": "npx clang-format -Werror -n",
|
|
231
|
+
}
|
|
232
|
+
// ...
|
|
233
|
+
}
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
1. Fix
|
|
237
|
+
|
|
238
|
+
```jsonc
|
|
239
|
+
/* package.json */
|
|
240
|
+
|
|
241
|
+
{
|
|
242
|
+
// ...
|
|
243
|
+
"lint-staged": {
|
|
244
|
+
"*.{c,cpp,h}": "npx clang-format -i",
|
|
245
|
+
}
|
|
246
|
+
// ...
|
|
247
|
+
}
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
> [!TIP]
|
|
251
|
+
>
|
|
252
|
+
> If `example1.cpp` and `example2.c` are staged, then `npx clang-format -Werror -n example1.cpp example2.c` will be excuted.
|
|
253
|
+
|
|
254
|
+
## Migration from 'angular/clang-format'
|
|
255
|
+
|
|
256
|
+
### `check-clang-format`
|
|
257
|
+
|
|
258
|
+
This package only uses native `clang-format` features to check formatting. The following commands will produce an error if the target files are not correctly formatted. So use them with `husky` and `lint-staged`. (`--dry-run` and `-n` options are equivalent.)
|
|
259
|
+
|
|
260
|
+
```bash
|
|
261
|
+
npx clang-format -Werror --dry-run example.cpp
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
```bash
|
|
265
|
+
npx clang-format -Werror -n example.cpp
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
### `git-clang-format`
|
|
269
|
+
|
|
270
|
+
Use [`husky`](https://typicode.github.io/husky/) and [`lint-staged`](https://github.com/lint-staged/lint-staged) for the `pre-commit` hook instead. See [Use with `husky` and `lint-staged`](#use-with-husky-and-lint-staged) for details.
|
|
271
|
+
|
|
272
|
+
## Contributing
|
|
273
|
+
|
|
274
|
+
Thanks for having attention to this package.🙇♂️ Issues and PRs are always welcome.🎉
|
|
275
|
+
|
|
276
|
+
I recommend you to read the guides on [LLVM and clang-format mentioned in issues tab](https://github.com/lumirlumir/npm-clang-format-node/issues/new/choose) before contributing.
|
|
277
|
+
|
|
278
|
+
### Installation
|
|
279
|
+
|
|
280
|
+
1. Fork it.
|
|
281
|
+
|
|
282
|
+
1. Clone it to your local directory. ([Git](https://git-scm.com/downloads) is required.)
|
|
283
|
+
|
|
284
|
+
```bash
|
|
285
|
+
git clone https://github.com/lumirlumir/npm-clang-format-node.git
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
1. Move to the `npm-clang-format-node` directory.
|
|
289
|
+
|
|
290
|
+
```bash
|
|
291
|
+
cd npm-clang-format-node
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
1. Install npm packages. ([Node.js](https://nodejs.org/en) is required.)
|
|
295
|
+
|
|
296
|
+
```bash
|
|
297
|
+
npm install
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
1. Edit codes.
|
|
301
|
+
|
|
302
|
+
1. Create `my-branch` branch.
|
|
303
|
+
|
|
304
|
+
```bash
|
|
305
|
+
git switch -c my-branch
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
1. Commit your changes. (`husky` and `lint-staged` will lint and test your changed files!)
|
|
309
|
+
|
|
310
|
+
```bash
|
|
311
|
+
git commit -am "commit type: title"
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
1. Push them to your remote branch.
|
|
315
|
+
|
|
316
|
+
1. Submit a pull request.👍
|
|
317
|
+
|
|
318
|
+
### About `os.platform()` and `os.arch()` in Node.js
|
|
319
|
+
|
|
320
|
+
#### [os.platform()](https://nodejs.org/docs/v20.17.0/api/os.html#osplatform)
|
|
321
|
+
|
|
322
|
+
The return value is equivalent to `process.platform`.
|
|
323
|
+
|
|
324
|
+
OS | return value of `os.platform()` |
|
|
325
|
+
------- | ---------------------------------- |
|
|
326
|
+
macOS | `darwin` |
|
|
327
|
+
Linux | `linux` |
|
|
328
|
+
Windows | `win32` |
|
|
329
|
+
|
|
330
|
+
#### [os.arch()](https://nodejs.org/docs/v20.17.0/api/os.html#osarch)
|
|
331
|
+
|
|
332
|
+
The return value is equivalent to `process.arch`.
|
|
333
|
+
|
|
334
|
+
Architecture | return value of `os.arch()` | LLVM | Docker Platform | Docker Ubuntu Image |
|
|
335
|
+
------------------ | ------------------------------ | --------- | --------------- | ------------------- |
|
|
336
|
+
arm(armv7, armv7l) | `arm` | `ARM` | `arm/v7` | `arm32v7` |
|
|
337
|
+
arm64 | `arm64` | `AArch64` | `arm64/v8` | `arm64v8` |
|
|
338
|
+
ppc64le[^1] | `ppc64` | `PowerPC` | `ppc64le` | `ppc64le` |
|
|
339
|
+
s390x | `s390x` | `SystemZ` | `s390x` | `s390x` |
|
|
340
|
+
x64 | `x64` | `X86` | `amd64` | `amd64` |
|
|
341
|
+
|
|
342
|
+
[^1]: `le` stands for little-endian, but the `os.arch()` function does not distinguish between endianness and returns a single value.
|
|
343
|
+
|
|
344
|
+
### Build process
|
|
345
|
+
|
|
346
|
+
Some packages for **cross-compilation** have been deprecated, making it difficult to make build processes directly, so **cross-compilation** is not used.
|
|
347
|
+
|
|
348
|
+
**Linux** is built using QEMU and Docker. **macOS** and **Windows** are built using the `macos-13`, `macos-14`, and `windows-latest` runners on GitHub Actions.
|
|
349
|
+
|
|
350
|
+
## Versioning
|
|
351
|
+
|
|
352
|
+
This project adheres to [Semantic Versioning](https://semver.org/).
|
|
353
|
+
|
|
354
|
+
[LLVM versions](https://github.com/llvm/llvm-project/releases) are managed as dependencies, so upgrading the LLVM version is treated as a 'patch'. Additionally, the release title includes the LLVM version, like `v1.0.0 (llvmorg-18.1.8)`.
|
|
355
|
+
|
|
356
|
+
See [`.clang-format-version`](/.clang-format-version) to check the exact current LLVM version.
|
|
357
|
+
|
|
358
|
+
## Change Log
|
|
359
|
+
|
|
360
|
+
See [`CHANGELOG.md`](/CHANGELOG.md)
|
|
361
|
+
|
|
362
|
+
## License
|
|
363
|
+
|
|
364
|
+
[MIT](/LICENSE) under [LLVM Apache License 2.0](https://github.com/llvm/llvm-project/blob/main/LICENSE.TXT)
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var _require=require("fs"),existsSync=_require.existsSync;var _require2=require("path"),resolve=_require2.resolve;module.exports=function(osPlatform,architecture){var clangFormatPath=resolve(__dirname,"bin","".concat(osPlatform,"-").concat(architecture),"clang-format".concat(osPlatform==="win32"?".exe":""));if(!existsSync(clangFormatPath))throw new Error("No executable found for '".concat(osPlatform,"(OS platform)-").concat(architecture,"(architecture)'\nSee supported OS platform and architecture lists of clang-format-node in README.md"));return clangFormatPath};
|
package/build/index.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";var _require=require("os"),platform=_require.platform,arch=_require.arch;var _require2=require("child_process"),spawn=_require2.spawn;var getClangFormatPath=require("./getClangFormatPath");var OS_PLATFORM=platform();var ARCHITECTURE=arch();try{var spawned=spawn(getClangFormatPath(OS_PLATFORM,ARCHITECTURE),process.argv.slice(2),{stdio:"inherit"});spawned.on("close",process.exit)}catch(error){console.error(error.message);process.exit(1)}
|
package/package.json
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "clang-format-node",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Node repackaging of the clang-format native binary inspired by angular/clang-format.🐉",
|
|
5
|
+
"main": "build/index.js",
|
|
6
|
+
"files": [
|
|
7
|
+
"build",
|
|
8
|
+
"LICENSE",
|
|
9
|
+
"README.md"
|
|
10
|
+
],
|
|
11
|
+
"bin": {
|
|
12
|
+
"clang-format": "build/index.js"
|
|
13
|
+
},
|
|
14
|
+
"keywords": [
|
|
15
|
+
"clang-format",
|
|
16
|
+
"clang",
|
|
17
|
+
"cli",
|
|
18
|
+
"format",
|
|
19
|
+
"formatter",
|
|
20
|
+
"lint",
|
|
21
|
+
"linter",
|
|
22
|
+
"cpplint",
|
|
23
|
+
"eslint",
|
|
24
|
+
"prettier",
|
|
25
|
+
"checker",
|
|
26
|
+
"c",
|
|
27
|
+
"cpp",
|
|
28
|
+
"c++"
|
|
29
|
+
],
|
|
30
|
+
"author": "루밀LuMir <rpfos@naver.com> (https://github.com/lumirlumir)",
|
|
31
|
+
"license": "MIT",
|
|
32
|
+
"homepage": "https://github.com/lumirlumir/npm-clang-format-node",
|
|
33
|
+
"repository": {
|
|
34
|
+
"type": "github",
|
|
35
|
+
"url": "git+https://github.com/lumirlumir/npm-clang-format-node.git"
|
|
36
|
+
},
|
|
37
|
+
"bugs": {
|
|
38
|
+
"url": "https://github.com/lumirlumir/npm-clang-format-node/issues"
|
|
39
|
+
},
|
|
40
|
+
"scripts": {
|
|
41
|
+
"prepare": "husky",
|
|
42
|
+
"prepublishOnly": "npm run build",
|
|
43
|
+
"build": "npx babel src -d build --no-comments --compact true --minified && cp -r src/bin build",
|
|
44
|
+
"test": "npx mocha ./tests --inline-diffs true",
|
|
45
|
+
"coverage": "npx nyc --reporter=lcov npm run test",
|
|
46
|
+
"lint": "concurrently \"npm:lint-*\"",
|
|
47
|
+
"lint-eslint": "npx eslint . --ext .js",
|
|
48
|
+
"lint-prettier": "npx prettier . --check",
|
|
49
|
+
"lint-editorconfig": "npx editorconfig-checker",
|
|
50
|
+
"lint-markdownlint": "npx markdownlint **/*.md",
|
|
51
|
+
"fix": "concurrently \"npm:fix-*\"",
|
|
52
|
+
"fix-eslint": "npx eslint . --fix --ext .js",
|
|
53
|
+
"fix-prettier": "npx prettier . --write"
|
|
54
|
+
},
|
|
55
|
+
"devDependencies": {
|
|
56
|
+
"@babel/cli": "^7.24.8",
|
|
57
|
+
"@babel/core": "^7.25.2",
|
|
58
|
+
"@babel/preset-env": "^7.25.3",
|
|
59
|
+
"concurrently": "^8.2.2",
|
|
60
|
+
"editorconfig-checker": "^5.1.8",
|
|
61
|
+
"eslint": "^8.57.0",
|
|
62
|
+
"eslint-config-airbnb-base": "^15.0.0",
|
|
63
|
+
"eslint-config-prettier": "^9.1.0",
|
|
64
|
+
"eslint-plugin-import": "^2.29.1",
|
|
65
|
+
"eslint-plugin-prettier": "^5.2.1",
|
|
66
|
+
"husky": "^9.1.5",
|
|
67
|
+
"lint-staged": "^15.2.10",
|
|
68
|
+
"markdownlint-cli": "^0.41.0",
|
|
69
|
+
"mocha": "^10.7.3",
|
|
70
|
+
"nyc": "^17.0.0",
|
|
71
|
+
"prettier": "^3.3.3"
|
|
72
|
+
},
|
|
73
|
+
"lint-staged": {
|
|
74
|
+
"*": [
|
|
75
|
+
"npx prettier --check",
|
|
76
|
+
"npx editorconfig-checker -exclude README.md"
|
|
77
|
+
],
|
|
78
|
+
"*.js": "npx eslint",
|
|
79
|
+
"*.md": "npx markdownlint",
|
|
80
|
+
"{src,tests}/**/!(index.js)": [
|
|
81
|
+
"npm run test"
|
|
82
|
+
]
|
|
83
|
+
}
|
|
84
|
+
}
|