diff --git a/scripts/generate_compression_test_files.luau b/scripts/generate_compression_test_files.luau index 8748436..1a3fd5a 100644 --- a/scripts/generate_compression_test_files.luau +++ b/scripts/generate_compression_test_files.luau @@ -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