diff options
| author | Hisham Muhammad <hisham@gobolinux.org> | 2012-09-18 20:55:57 -0300 |
|---|---|---|
| committer | Hisham Muhammad <hisham@gobolinux.org> | 2012-09-18 20:55:57 -0300 |
| commit | 496dc3d8ea8d65082dcfb6d5aa44353c3fd0433d (patch) | |
| tree | 0fe806c43751c5e1d552e67c92a135038d8a4d64 /src | |
| parent | af2b92b5a922ecdb18c8d4ab202ab84a44125cf2 (diff) | |
| download | luarocks-496dc3d8ea8d65082dcfb6d5aa44353c3fd0433d.tar.gz luarocks-496dc3d8ea8d65082dcfb6d5aa44353c3fd0433d.tar.bz2 luarocks-496dc3d8ea8d65082dcfb6d5aa44353c3fd0433d.zip | |
Add 'lint' command, to check for rockspec validity.
Diffstat (limited to 'src')
| -rwxr-xr-x | src/bin/luarocks | 1 | ||||
| -rw-r--r-- | src/luarocks/lint.lua | 37 |
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") | |||
| 19 | commands.path = require("luarocks.path") | 19 | commands.path = require("luarocks.path") |
| 20 | commands.show = require("luarocks.show") | 20 | commands.show = require("luarocks.show") |
| 21 | commands.new_version = require("luarocks.new_version") | 21 | commands.new_version = require("luarocks.new_version") |
| 22 | commands.lint = require("luarocks.lint") | ||
| 22 | 23 | ||
| 23 | command_line.run_command(...) | 24 | command_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. | ||
| 4 | module("luarocks.lint", package.seeall) | ||
| 5 | |||
| 6 | local util = require("luarocks.util") | ||
| 7 | local download = require("luarocks.download") | ||
| 8 | local fetch = require("luarocks.fetch") | ||
| 9 | |||
| 10 | help_summary = "Check syntax of a rockspec." | ||
| 11 | help_arguments = "<rockspec>" | ||
| 12 | help = [[ | ||
| 13 | This is a utility function that checks the syntax of a rockspec. | ||
| 14 | |||
| 15 | It reports success or failure if the text of a rockspec is | ||
| 16 | syntactically correct. | ||
| 17 | ]] | ||
| 18 | |||
| 19 | function 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 | ||
| 37 | end | ||
