We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 886a03d commit 85f067aCopy full SHA for 85f067a
3 files changed
.travis.yml
@@ -112,6 +112,20 @@ matrix:
112
script: npm run test-all
113
node_js: "10"
114
115
+ ##########
116
+ # Linter #
117
118
+
119
+ - name: "Linter"
120
+ sudo: required
121
+ dist: trusty
122
+ before_install:
123
+ - sudo apt-get -qq update
124
+ - sudo apt-get install lldb-3.9 liblldb-3.9-dev -y
125
+ install: npm install
126
+ script: npm run linter
127
+ node_js: "10"
128
129
# Allow the nightly installs to fail
130
allow_failures:
131
package.json
@@ -25,6 +25,7 @@
25
"codecov-upload-cc": "codecov --disable=gcov --file=coverage-cc.info",
26
"codecov-upload-js": "codecov --disable=gcov --file=coverage-js.lcov",
27
"codecov-upload": "npm run codecov-upload-cc && npm run codecov-upload-js",
28
+ "linter": "node scripts/linter.js",
29
"format": "clang-format -i src/*"
30
},
31
"repository": {
scripts/linter.js
@@ -0,0 +1,41 @@
1
+'use strict';
2
3
+const { getNativeBinary } = require("clang-format");
4
+const { exec } = require("child_process");
5
+const { readdir, readFile } = require("fs");
6
7
+const dirtyFiles = [];
8
9
+process.on("exit", () => {
10
+ if (dirtyFiles.length == 0) {
11
+ return;
12
+ }
13
+ process.exitCode = 1;
14
+ process._rawDebug("The following files are not formatted correctly:");
15
+ for (let file of dirtyFiles) {
16
+ process._rawDebug(` ${file}`);
17
18
19
+});
20
21
+readdir("./src/", (err, files) => {
22
+ for (let file of files) {
23
+ readFile(`./src/${file}`, {encoding: 'utf8'}, (err, data) => {
24
+ if (err) {
+ console.error(err);
+ process.exitCode = 2;
+ exec(`${getNativeBinary()} src/${file}`, {maxBuffer: 1024 * 1024 * 5}, (err, stdout, stderr) => {
32
33
34
35
+ if (stdout.trim() != data.trim()) {
36
+ dirtyFiles.push(file);
37
38
+ });
39
40
41
0 commit comments