diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/luarocks/cmd/lint.tl (renamed from src/luarocks/cmd/lint.lua) | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/src/luarocks/cmd/lint.lua b/src/luarocks/cmd/lint.tl index 738503ce..9f3db2d4 100644 --- a/src/luarocks/cmd/lint.lua +++ b/src/luarocks/cmd/lint.tl | |||
| @@ -1,13 +1,19 @@ | |||
| 1 | 1 | ||
| 2 | --- Module implementing the LuaRocks "lint" command. | 2 | --- Module implementing the LuaRocks "lint" command. |
| 3 | -- Utility function that checks syntax of the rockspec. | 3 | -- Utility function that checks syntax of the rockspec. |
| 4 | local lint = {} | 4 | local record lint |
| 5 | end | ||
| 5 | 6 | ||
| 6 | local util = require("luarocks.util") | 7 | local util = require("luarocks.util") |
| 7 | local download = require("luarocks.download") | 8 | local download = require("luarocks.download") |
| 8 | local fetch = require("luarocks.fetch") | 9 | local fetch = require("luarocks.fetch") |
| 9 | 10 | ||
| 10 | function lint.add_to_parser(parser) | 11 | local argparse = require("luarocks.vendor.argparse") |
| 12 | local type Parser = argparse.Parser | ||
| 13 | |||
| 14 | local type Args = require("luarocks.core.types.args").Args | ||
| 15 | |||
| 16 | function lint.add_to_parser(parser: Parser) | ||
| 11 | local cmd = parser:command("lint", "Check syntax of a rockspec.\n\n".. | 17 | local cmd = parser:command("lint", "Check syntax of a rockspec.\n\n".. |
| 12 | "Returns success if the text of the rockspec is syntactically correct, else failure.", | 18 | "Returns success if the text of the rockspec is syntactically correct, else failure.", |
| 13 | util.see_also()) | 19 | util.see_also()) |
| @@ -16,12 +22,12 @@ function lint.add_to_parser(parser) | |||
| 16 | cmd:argument("rockspec", "The rockspec to check.") | 22 | cmd:argument("rockspec", "The rockspec to check.") |
| 17 | end | 23 | end |
| 18 | 24 | ||
| 19 | function lint.command(args) | 25 | function lint.command(args: Args): boolean, string, string |
| 20 | 26 | ||
| 21 | local filename = args.rockspec | 27 | local filename = args.rockspec |
| 22 | if not filename:match(".rockspec$") then | 28 | if not filename:match(".rockspec$") then |
| 23 | local err | 29 | local err: string |
| 24 | filename, err = download.download("rockspec", filename:lower()) | 30 | filename, err = download.download_file("rockspec", filename:lower()) |
| 25 | if not filename then | 31 | if not filename then |
| 26 | return nil, err | 32 | return nil, err |
| 27 | end | 33 | end |
| @@ -44,7 +50,11 @@ function lint.command(args) | |||
| 44 | ok = false | 50 | ok = false |
| 45 | end | 51 | end |
| 46 | 52 | ||
| 47 | return ok, ok or filename.." failed consistency checks." | 53 | if ok then |
| 54 | return ok | ||
| 55 | end | ||
| 56 | |||
| 57 | return nil, filename.." failed consistency checks." | ||
| 48 | end | 58 | end |
| 49 | 59 | ||
| 50 | return lint | 60 | return lint |
