Skip to content

Commit

Permalink
Don't put array items on the same line when persisting
Browse files Browse the repository at this point in the history
Rockspec fields with array values (e.g. dependencies) are
typically written with each item on its own line. This change
makes `luarocks new-version` follow this style, too.
  • Loading branch information
mpeterv committed May 22, 2016
1 parent bc81a0b commit 7b23838
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions src/luarocks/persist.lua
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,10 @@ write_table = function(out, tbl, level, field_order)
out:write("{")
local sep = "\n"
local indentation = " "
local indent = true
local i = 1
for k, v, sub_order in util.sortedpairs(tbl, field_order) do
out:write(sep)
if indent then
for n = 1,level do out:write(indentation) end
end
out:write(indentation:rep(level))

if k == i then
i = i + 1
Expand All @@ -147,17 +144,11 @@ write_table = function(out, tbl, level, field_order)
end

write_value(out, v, level, sub_order)
if type(k) == "number" then
sep = ", "
indent = false
else
sep = ",\n"
indent = true
end
sep = ",\n"
end
if sep ~= "\n" then
out:write("\n")
for n = 1,level-1 do out:write(indentation) end
out:write(indentation:rep(level - 1))
end
out:write("}")
end
Expand Down

0 comments on commit 7b23838

Please sign in to comment.