aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHisham Muhammad <hisham@gobolinux.org>2019-11-12 19:07:24 -0300
committerHisham Muhammad <hisham@gobolinux.org>2019-11-29 18:36:42 -0300
commit51a2c592405c6c9fc006014973229ce1ac011d21 (patch)
tree33c53d2352f88fe8896bcfbb6a183df1c2f2566b
parentc00be6f54916528883fdf79b1ff99263b7a93fb5 (diff)
downloadluarocks-51a2c592405c6c9fc006014973229ce1ac011d21.tar.gz
luarocks-51a2c592405c6c9fc006014973229ce1ac011d21.tar.bz2
luarocks-51a2c592405c6c9fc006014973229ce1ac011d21.zip
config: fix --unset
-rw-r--r--spec/config_spec.lua21
-rw-r--r--src/luarocks/cmd/config.lua2
2 files changed, 22 insertions, 1 deletions
diff --git a/spec/config_spec.lua b/spec/config_spec.lua
index 2e76ae0c..f4a793c4 100644
--- a/spec/config_spec.lua
+++ b/spec/config_spec.lua
@@ -170,6 +170,27 @@ describe("LuaRocks config tests #integration", function()
170 end) 170 end)
171 end) 171 end)
172 172
173 describe("unset config keys", function()
174 it("unsets a simple config key", function()
175 test_env.run_in_tmp(function(tmpdir)
176 local myproject = tmpdir .. "/myproject"
177 lfs.mkdir(myproject)
178 lfs.chdir(myproject)
179
180 assert(run.luarocks("init"))
181 assert.truthy(run.luarocks_bool("config my_var my_value"))
182
183 local output = run.luarocks("config my_var")
184 assert.match("my_value", output)
185
186 assert.truthy(run.luarocks_bool("config my_var --unset"))
187
188 output = run.luarocks("config my_var")
189 assert.not_match("my_value", output)
190 end, finally)
191 end)
192 end)
193
173 describe("write config keys", function() 194 describe("write config keys", function()
174 it("rejects invalid --scope", function() 195 it("rejects invalid --scope", function()
175 assert.is_false(run.luarocks_bool("config web_browser foo --scope=foo")) 196 assert.is_false(run.luarocks_bool("config web_browser foo --scope=foo"))
diff --git a/src/luarocks/cmd/config.lua b/src/luarocks/cmd/config.lua
index 59dafdb5..6d3543b5 100644
--- a/src/luarocks/cmd/config.lua
+++ b/src/luarocks/cmd/config.lua
@@ -302,7 +302,7 @@ function config_cmd.command(args)
302 if args.key then 302 if args.key then
303 if args.value or args.unset then 303 if args.value or args.unset then
304 local scope = get_scope(args) 304 local scope = get_scope(args)
305 return write_entries({ [args.key] = args.value }, scope, args.unset) 305 return write_entries({ [args.key] = args.value or args.unset }, scope, args.unset)
306 else 306 else
307 return print_entry(args.key, cfg, args.json) 307 return print_entry(args.key, cfg, args.json)
308 end 308 end