mirror of
https://github.com/lune-org/lune.git
synced 2025-04-04 10:30:54 +01:00
Show file diff before trying to decompress
This commit is contained in:
parent
57323e55c0
commit
237da52071
1 changed files with 20 additions and 20 deletions
|
@ -190,6 +190,26 @@ for _, spec in OUTPUT_FILES do
|
|||
)
|
||||
end
|
||||
|
||||
-- If the newly compressed contents do not match the existing contents,
|
||||
-- warn the user about this and ask if they want to overwrite the file
|
||||
local existingContents = fs.readFile(spec.final)
|
||||
if compressedContents ~= existingContents then
|
||||
stdio.ewrite("\nCompressed file does not match existing contents!")
|
||||
stdio.ewrite("\n\nExisting:\n")
|
||||
stdio.ewrite(stringAsHex(existingContents))
|
||||
stdio.ewrite("\n\nCompressed:\n")
|
||||
stdio.ewrite(hexDiff(existingContents, compressedContents))
|
||||
stdio.ewrite("\n\n")
|
||||
local confirm = stdio.prompt("confirm", "Do you want to continue?")
|
||||
if confirm == true then
|
||||
print("Overwriting file!")
|
||||
else
|
||||
stdio.ewrite("\n\nAborting...\n")
|
||||
process.exit(1)
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
-- Check if the compressed contents can be decompressed using serde
|
||||
local decompressSuccess, decompressedContents =
|
||||
pcall(serde.decompress, spec.format, compressedContents)
|
||||
|
@ -227,26 +247,6 @@ for _, spec in OUTPUT_FILES do
|
|||
end
|
||||
end
|
||||
|
||||
-- If the newly compressed contents do not match the existing contents,
|
||||
-- warn the user about this and ask if they want to overwrite the file
|
||||
local existingContents = fs.readFile(spec.final)
|
||||
if compressedContents ~= existingContents then
|
||||
stdio.ewrite("\nCompressed file does not match existing contents!")
|
||||
stdio.ewrite("\n\nExisting:\n")
|
||||
stdio.ewrite(stringAsHex(existingContents))
|
||||
stdio.ewrite("\n\nCompressed:\n")
|
||||
stdio.ewrite(hexDiff(existingContents, compressedContents))
|
||||
stdio.ewrite("\n\n")
|
||||
local confirm = stdio.prompt("confirm", "Do you want to continue?")
|
||||
if confirm == true then
|
||||
print("Overwriting file!")
|
||||
else
|
||||
stdio.ewrite("\n\nAborting...\n")
|
||||
process.exit(1)
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
-- Check if the compressed contents match the serde compressed contents,
|
||||
-- if they don't this will 100% make the tests fail, but maybe we are doing
|
||||
-- it because we are updating the serde library and need to update test files
|
||||
|
|
Loading…
Add table
Reference in a new issue