Skip to content

Commit e3484ba

Browse files
committed
Use number of issues as exit code
1 parent 0c6cdc7 commit e3484ba

File tree

2 files changed

+5
-14
lines changed

2 files changed

+5
-14
lines changed

spec/cli_spec.lua

+4-4
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ Checking spec/samples/bad_code.lua 5 warnings
117117
118118
Total: 5 warnings / 0 errors in 1 file
119119
]], get_output "spec/samples/bad_code.lua --no-config")
120-
assert.equal(1, get_exitcode "spec/samples/bad_code.lua --no-config")
120+
assert.equal(5, get_exitcode "spec/samples/bad_code.lua --no-config")
121121
end)
122122

123123
it("detects whitespace issues", function()
@@ -135,7 +135,7 @@ Checking spec/samples/bad_whitespace.lua 8 warnings
135135
136136
Total: 8 warnings / 0 errors in 1 file
137137
]], get_output "spec/samples/bad_whitespace.lua --no-config")
138-
assert.equal(1, get_exitcode "spec/samples/bad_whitespace.lua --no-config")
138+
assert.equal(8, get_exitcode "spec/samples/bad_whitespace.lua --no-config")
139139
end)
140140

141141
it("works for incorrect patterns in options", function()
@@ -1216,11 +1216,11 @@ Critical error: Couldn't find configuration file spec/configs/config_404.luachec
12161216

12171217
describe("overwriting", function()
12181218
it("prioritizes CLI options over config", function()
1219-
assert.equal(1, get_exitcode "spec/samples/compat.lua --config=spec/configs/cli_override_config.luacheckrc --new-globals foo")
1219+
assert.is_true(get_exitcode "spec/samples/compat.lua --config=spec/configs/cli_override_config.luacheckrc --new-globals foo" > 0)
12201220
end)
12211221

12221222
it("prioritizes CLI options over config overrides", function()
1223-
assert.equal(1, get_exitcode "spec/samples/compat.lua --config=spec/configs/cli_override_file_config.luacheckrc --new-globals foo")
1223+
assert.is_true(get_exitcode "spec/samples/compat.lua --config=spec/configs/cli_override_file_config.luacheckrc --new-globals foo" > 0)
12241224
end)
12251225

12261226
it("concats array-like options from config and CLI", function()

src/luacheck/main.lua

+1-10
Original file line numberDiff line numberDiff line change
@@ -523,16 +523,7 @@ patterns.]])
523523

524524
io.stdout:write(output)
525525

526-
local exit_code
527-
528-
if report.fatals > 0 then
529-
exit_code = 2
530-
elseif report.warnings > 0 or report.errors > 0 then
531-
exit_code = 1
532-
else
533-
exit_code = 0
534-
end
535-
526+
local exit_code = math.min(report.fatals + report.errors + report.warnings, 255)
536527
os.exit(exit_code)
537528
end
538529

0 commit comments

Comments
 (0)