From bb8df68c109bb860df57563d51003034a57bf7e1 Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Mon, 19 Feb 2024 14:14:43 -0300 Subject: fix(config): print boolean values correctly on Lua 5.1 --- spec/config_spec.lua | 14 ++++++++++++++ src/luarocks/cmd/config.lua | 6 +++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/spec/config_spec.lua b/spec/config_spec.lua index 05da0007..98fcb24c 100644 --- a/spec/config_spec.lua +++ b/spec/config_spec.lua @@ -238,6 +238,20 @@ describe("LuaRocks config tests #integration", function() end, finally) end) + it("writes a boolean config key", function() + test_env.run_in_tmp(function(tmpdir) + local myproject = tmpdir .. "/myproject" + lfs.mkdir(myproject) + lfs.chdir(myproject) + + assert(run.luarocks("init")) + assert.truthy(run.luarocks_bool("config hooks_enabled true")) + + local output = run.luarocks("config hooks_enabled") + assert.match("true", output) + end, finally) + end) + it("writes an array config key", function() test_env.run_in_tmp(function(tmpdir) local myproject = tmpdir .. "/myproject" diff --git a/src/luarocks/cmd/config.lua b/src/luarocks/cmd/config.lua index 0e7a3e3d..a01d33a9 100644 --- a/src/luarocks/cmd/config.lua +++ b/src/luarocks/cmd/config.lua @@ -219,7 +219,11 @@ local function write_entries(keys, scope, do_unset) if do_unset then print(("\t%s"):format(var)) else - print(("\t%s = %q"):format(var, val)) + if type(val) == "string" then + print(("\t%s = %q"):format(var, val)) + else + print(("\t%s = %s"):format(var, tostring(val))) + end end end print(do_unset and "from" or "to") -- cgit v1.2.3-55-g6feb