diff options
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 | ||
