Skip to content

Commit 3867759

Browse files
committed
Support pre-commit hooks
Fix #2343
1 parent 7f76050 commit 3867759

File tree

3 files changed

+18
-5
lines changed

3 files changed

+18
-5
lines changed

.pre-commit-hooks.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
- id: lua-language-server-check
3+
name: lua language server check
4+
description: >
5+
linter for lua
6+
entry: lua-language-server
7+
language: lua
8+
types:
9+
- lua
10+
args:
11+
- --check

script/cli/check.lua

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,9 @@ for i = 1, numThreads do
6969
end
7070
end
7171

72+
local checkPassed = true
7273
for _, process in ipairs(procs) do
73-
process:wait()
74+
checkPassed = process:wait() == 0 and checkPassed
7475
end
7576

7677
local outpath = CHECK_OUT_PATH
@@ -99,3 +100,4 @@ if numThreads > 1 then
99100
print(lang.script('CLI_CHECK_RESULTS', count, outpath))
100101
end
101102
end
103+
return checkPassed

script/cli/init.lua

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ if _G['VERSION'] then
44
end
55

66
if _G['CHECK'] then
7-
require 'cli.check'
8-
os.exit(0, true)
7+
local checkPassed = require 'cli.check'
8+
os.exit(checkPassed and 0 or 1, true)
99
end
1010

1111
if _G['CHECK_WORKER'] then
12-
require 'cli.check_worker'
13-
os.exit(0, true)
12+
local checkPassed = require 'cli.check_worker'
13+
os.exit(checkPassed and 0 or 1, true)
1414
end
1515

1616
if _G['DOC_UPDATE'] then

0 commit comments

Comments
 (0)