From ec5625a3fb2060d9e7dd27771994fd17e91696ab Mon Sep 17 00:00:00 2001 From: Filip Tibell Date: Sat, 11 May 2024 22:03:55 +0200 Subject: [PATCH] Make output of generation script friendlier --- scripts/generate_compression_test_files.luau | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/scripts/generate_compression_test_files.luau b/scripts/generate_compression_test_files.luau index 8b5ed38..8574999 100644 --- a/scripts/generate_compression_test_files.luau +++ b/scripts/generate_compression_test_files.luau @@ -63,6 +63,14 @@ local function hexDiff(a: string, b: string): string return table.concat(diff) end +local function stripCwdIfPresent(path: string): string + if string.sub(path, 1, #process.cwd) == process.cwd then + return string.sub(path, #process.cwd + 1) + else + return path + end +end + -- Make some processing functions for manipulating output of certain commands local function processNoop(output: string): string @@ -178,7 +186,11 @@ for _, spec in OUTPUT_FILES do -- Write the temp file for the compression tool to read and use, then -- remove it, some tools may remove it on their own, so we ignore errors fs.writeFile(TEMP_FILE, INPUT_FILE_CONTENTS) - print("\nRunning", spec.command, "with args", table.concat(spec.args, " ")) + local argsToDisplay = {} + for _, arg in spec.args do + table.insert(argsToDisplay, stripCwdIfPresent(arg)) + end + print("\nRunning", spec.command, "with args", table.concat(argsToDisplay, " ")) local output = run(spec.command, spec.args) if #output > 0 then print("Output:", output) @@ -282,5 +294,5 @@ for _, spec in OUTPUT_FILES do -- Finally, write the new compressed file fs.writeFile(spec.final, compressedContents) - print("Wrote new file successfully to", spec.final) + print("Wrote new file successfully to", stripCwdIfPresent(spec.final)) end