aboutsummaryrefslogtreecommitdiff
path: root/src/luarocks/cmd/lint.lua
diff options
context:
space:
mode:
Diffstat (limited to 'src/luarocks/cmd/lint.lua')
-rw-r--r--src/luarocks/cmd/lint.lua59
1 files changed, 59 insertions, 0 deletions
diff --git a/src/luarocks/cmd/lint.lua b/src/luarocks/cmd/lint.lua
new file mode 100644
index 00000000..7a8443cc
--- /dev/null
+++ b/src/luarocks/cmd/lint.lua
@@ -0,0 +1,59 @@
1local _tl_compat; if (tonumber((_VERSION or ''):match('[%d.]*$')) or 0) < 5.3 then local p, m = pcall(require, 'compat53.module'); if p then _tl_compat = m end end; local string = _tl_compat and _tl_compat.string or string
2
3
4local lint = {}
5
6
7local util = require("luarocks.util")
8local download = require("luarocks.download")
9local fetch = require("luarocks.fetch")
10
11
12
13
14
15function lint.add_to_parser(parser)
16 local cmd = parser:command("lint", "Check syntax of a rockspec.\n\n" ..
17 "Returns success if the text of the rockspec is syntactically correct, else failure.",
18 util.see_also()):
19 summary("Check syntax of a rockspec.")
20
21 cmd:argument("rockspec", "The rockspec to check.")
22end
23
24function lint.command(args)
25
26 local filename = args.rockspec
27 if not filename:match(".rockspec$") then
28 local err
29 filename, err = download.download_file("rockspec", filename:lower())
30 if not filename then
31 return nil, err
32 end
33 end
34
35 local rs, err = fetch.load_local_rockspec(filename)
36 if not rs then
37 return nil, "Failed loading rockspec: " .. err
38 end
39
40 local ok = true
41
42
43
44
45
46
47 if not rs.description or not rs.description.license then
48 util.printerr("Rockspec has no description.license field.")
49 ok = false
50 end
51
52 if ok then
53 return ok
54 end
55
56 return nil, filename .. " failed consistency checks."
57end
58
59return lint