diff options
| author | Hisham Muhammad <hisham@gobolinux.org> | 2024-02-19 14:14:43 -0300 |
|---|---|---|
| committer | Hisham Muhammad <hisham@gobolinux.org> | 2024-02-19 19:34:40 -0300 |
| commit | bb8df68c109bb860df57563d51003034a57bf7e1 (patch) | |
| tree | aa727315a879ebc246bc889a206549a9013cc610 | |
| parent | 4e1376fa8840f0055dab5c0e7dbcd8cc1c281b6d (diff) | |
| download | luarocks-bb8df68c109bb860df57563d51003034a57bf7e1.tar.gz luarocks-bb8df68c109bb860df57563d51003034a57bf7e1.tar.bz2 luarocks-bb8df68c109bb860df57563d51003034a57bf7e1.zip | |
fix(config): print boolean values correctly on Lua 5.1
| -rw-r--r-- | spec/config_spec.lua | 14 | ||||
| -rw-r--r-- | src/luarocks/cmd/config.lua | 6 |
2 files changed, 19 insertions, 1 deletions
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() | |||
| 238 | end, finally) | 238 | end, finally) |
| 239 | end) | 239 | end) |
| 240 | 240 | ||
| 241 | it("writes a boolean config key", function() | ||
| 242 | test_env.run_in_tmp(function(tmpdir) | ||
| 243 | local myproject = tmpdir .. "/myproject" | ||
| 244 | lfs.mkdir(myproject) | ||
| 245 | lfs.chdir(myproject) | ||
| 246 | |||
| 247 | assert(run.luarocks("init")) | ||
| 248 | assert.truthy(run.luarocks_bool("config hooks_enabled true")) | ||
| 249 | |||
| 250 | local output = run.luarocks("config hooks_enabled") | ||
| 251 | assert.match("true", output) | ||
| 252 | end, finally) | ||
| 253 | end) | ||
| 254 | |||
| 241 | it("writes an array config key", function() | 255 | it("writes an array config key", function() |
| 242 | test_env.run_in_tmp(function(tmpdir) | 256 | test_env.run_in_tmp(function(tmpdir) |
| 243 | local myproject = tmpdir .. "/myproject" | 257 | 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) | |||
| 219 | if do_unset then | 219 | if do_unset then |
| 220 | print(("\t%s"):format(var)) | 220 | print(("\t%s"):format(var)) |
| 221 | else | 221 | else |
| 222 | print(("\t%s = %q"):format(var, val)) | 222 | if type(val) == "string" then |
| 223 | print(("\t%s = %q"):format(var, val)) | ||
| 224 | else | ||
| 225 | print(("\t%s = %s"):format(var, tostring(val))) | ||
| 226 | end | ||
| 223 | end | 227 | end |
| 224 | end | 228 | end |
| 225 | print(do_unset and "from" or "to") | 229 | print(do_unset and "from" or "to") |
