aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHisham Muhammad <hisham@gobolinux.org>2012-09-18 20:55:57 -0300
committerHisham Muhammad <hisham@gobolinux.org>2012-09-18 20:55:57 -0300
commit496dc3d8ea8d65082dcfb6d5aa44353c3fd0433d (patch)
tree0fe806c43751c5e1d552e67c92a135038d8a4d64
parentaf2b92b5a922ecdb18c8d4ab202ab84a44125cf2 (diff)
downloadluarocks-496dc3d8ea8d65082dcfb6d5aa44353c3fd0433d.tar.gz
luarocks-496dc3d8ea8d65082dcfb6d5aa44353c3fd0433d.tar.bz2
luarocks-496dc3d8ea8d65082dcfb6d5aa44353c3fd0433d.zip
Add 'lint' command, to check for rockspec validity.
-rwxr-xr-xsrc/bin/luarocks1
-rw-r--r--src/luarocks/lint.lua37
2 files changed, 38 insertions, 0 deletions
diff --git a/src/bin/luarocks b/src/bin/luarocks
index 1397bbd0..e94d895f 100755
--- a/src/bin/luarocks
+++ b/src/bin/luarocks
@@ -19,5 +19,6 @@ commands.download = require("luarocks.download")
19commands.path = require("luarocks.path") 19commands.path = require("luarocks.path")
20commands.show = require("luarocks.show") 20commands.show = require("luarocks.show")
21commands.new_version = require("luarocks.new_version") 21commands.new_version = require("luarocks.new_version")
22commands.lint = require("luarocks.lint")
22 23
23command_line.run_command(...) 24command_line.run_command(...)
diff --git a/src/luarocks/lint.lua b/src/luarocks/lint.lua
new file mode 100644
index 00000000..63b549aa
--- /dev/null
+++ b/src/luarocks/lint.lua
@@ -0,0 +1,37 @@
1
2--- Module implementing the LuaRocks "lint" command.
3-- Utility function that checks syntax of the rockspec.
4module("luarocks.lint", package.seeall)
5
6local util = require("luarocks.util")
7local download = require("luarocks.download")
8local fetch = require("luarocks.fetch")
9
10help_summary = "Check syntax of a rockspec."
11help_arguments = "<rockspec>"
12help = [[
13This is a utility function that checks the syntax of a rockspec.
14
15It reports success or failure if the text of a rockspec is
16syntactically correct.
17]]
18
19function run(...)
20 local flags, input = util.parse_flags(...)
21
22 local filename = input
23 if not input:match(".rockspec$") then
24 local err
25 filename, err = download.download("rockspec", input)
26 if not filename then
27 return nil, err
28 end
29 end
30
31 local rs, err = fetch.load_local_rockspec(filename)
32 if not rs then
33 return nil, "Failed loading rockspec: "..err
34 end
35
36 return true
37end