diff options
author | Hisham Muhammad <hisham@gobolinux.org> | 2024-02-19 13:51:09 -0300 |
---|---|---|
committer | Hisham Muhammad <hisham@gobolinux.org> | 2024-02-19 19:34:27 -0300 |
commit | 4e1376fa8840f0055dab5c0e7dbcd8cc1c281b6d (patch) | |
tree | 55cc9670b98d9ee21305e42dfb0f993889f6179a | |
parent | c13ff298bdd424d7b7401fce4f0379cda0348af8 (diff) | |
download | luarocks-4e1376fa8840f0055dab5c0e7dbcd8cc1c281b6d.tar.gz luarocks-4e1376fa8840f0055dab5c0e7dbcd8cc1c281b6d.tar.bz2 luarocks-4e1376fa8840f0055dab5c0e7dbcd8cc1c281b6d.zip |
fix(lint): don't crash when missing description
-rw-r--r-- | spec/lint_spec.lua | 14 | ||||
-rw-r--r-- | src/luarocks/cmd/lint.lua | 4 |
2 files changed, 16 insertions, 2 deletions
diff --git a/spec/lint_spec.lua b/spec/lint_spec.lua index b205cc57..847c9800 100644 --- a/spec/lint_spec.lua +++ b/spec/lint_spec.lua | |||
@@ -93,5 +93,19 @@ describe("luarocks lint #integration", function() | |||
93 | ]], finally) | 93 | ]], finally) |
94 | assert.is_false(run.luarocks_bool("lint no_build_table-1.0-1.rockspec")) | 94 | assert.is_false(run.luarocks_bool("lint no_build_table-1.0-1.rockspec")) |
95 | end) | 95 | end) |
96 | |||
97 | it("no description field", function() | ||
98 | write_file("nodesc-1.0-1.rockspec", [[ | ||
99 | package = "nodesc" | ||
100 | version = "0.1-1" | ||
101 | source = { | ||
102 | url = "http://example.com/foo/tar.gz" | ||
103 | } | ||
104 | dependencies = { | ||
105 | "lua >= 5.1" | ||
106 | } | ||
107 | ]], finally) | ||
108 | assert.is_false(run.luarocks_bool("lint nodesc-1.0-1.rockspec")) | ||
109 | end) | ||
96 | end) | 110 | end) |
97 | end) | 111 | end) |
diff --git a/src/luarocks/cmd/lint.lua b/src/luarocks/cmd/lint.lua index 47a3da90..738503ce 100644 --- a/src/luarocks/cmd/lint.lua +++ b/src/luarocks/cmd/lint.lua | |||
@@ -39,8 +39,8 @@ function lint.command(args) | |||
39 | -- Making 'lint' alone be stricter shouldn't be a problem, | 39 | -- Making 'lint' alone be stricter shouldn't be a problem, |
40 | -- because extra-strict checks is what lint-type commands | 40 | -- because extra-strict checks is what lint-type commands |
41 | -- are all about. | 41 | -- are all about. |
42 | if not rs.description.license then | 42 | if not rs.description or not rs.description.license then |
43 | util.printerr("Rockspec has no license field.") | 43 | util.printerr("Rockspec has no description.license field.") |
44 | ok = false | 44 | ok = false |
45 | end | 45 | end |
46 | 46 | ||