fix: substitute version on platforms with different line endings

This commit is contained in:
daimond113 2024-12-15 01:03:03 +01:00
parent 52c8992fe3
commit d219a8b668
No known key found for this signature in database
GPG key ID: 3A8ECE51328B513C

View file

@ -138,12 +138,18 @@ for _, binSrc in pathfs.readDir(BINS_SRC_DIR) do
-- HACK: To prevent messing with our existing toml ordering and formatting
-- we just replace the old version field string with the new version field
-- string
-- the string returned by serde.encode end with newlines, so remove them to maintain compatibility with different line endings
-- Old version field string:
local oldField = string.gsub(serde.encode("toml", { version = manifest.version }), "%s+$", "")
-- New version field string:
local newField = string.gsub(serde.encode("toml", { version = stripLeadingVersion(newVersion) }), "%s+$", "")
local updatedManifest = string.gsub(
manifestContents,
-- Old version field string:
serde.encode("toml", { version = manifest.version }),
-- New version field string:
serde.encode("toml", { version = stripLeadingVersion(newVersion) }),
oldField,
newField,
-- Only replace the first occurrence to be safe
1
)