Improved array handling: Fixes for issue npm/ini#52 and should also fix npm/ini#56 #74
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
For instance handling systemd-networkd
.network
files is now working for duplicate keys. An example is provided below.For a
eth0.network
file:The file is now parsed to:
And encoded to the following string when using the new option
isArray
(Ideas for better naming are welcome):ini.stringify(parsed, { isArray: false})
"[Match]\nName=eth0\n\n[Network]\nAddress=172.16.1.99/24\nGateway=172.16.1.1\nDNS=172.16.1.1\nDNS=8.8.8.8\n"
otherwise if you prefer to have
[]
present as a suffix after the key in a.ini
file and it does not corrupt what the file is used for you can do as follows:ini.stringify(parsed, { isArray: true})
or
ini.stringify(parsed)
will return:
"[Match]\nName=eth0\n\n[Match.Network]\nAddress=172.16.1.99/24\nGateway=172.16.1.1\nDNS[]=172.16.1.1\nDNS[]=8.8.8.8\n"