diff --git a/_reporter.js b/_reporter.js index b4085e1..4284db0 100644 --- a/_reporter.js +++ b/_reporter.js @@ -6,7 +6,9 @@ const path = require("path"); const oldData = JSON.parse(process.argv[2]); const newData = JSON.parse(process.argv[3]); const contractPath = path.parse(process.argv[4]); +const ignoreNew = JSON.parse(process.argv[5]); +console.log("Ignore is :", ignoreNew); // Skip if same if (JSON.stringify(oldData) === JSON.stringify(newData)) process.exit(0); @@ -101,8 +103,10 @@ for (; i < alignedOldVisualized.length; i++) { } } else { if (!hasExisted(overlayedItem, oldVisualized)) { + if(!ignoreNew){ printNew(true, "🌱"); printOld(false); + } } else { printNew(true, "đŸŗī¸"); printOld(false); @@ -115,12 +119,29 @@ for (; i < alignedOldVisualized.length; i++) { } } +// =========== ignore_if_all_new ========================== + +// Function to check for the presence of specified emojis +function containsEmojis(str) { + const emojis = ["🏴", "đŸŗī¸", "🏁", "đŸĒĻ"]; + return emojis.some(emoji => str.includes(emoji)); +} + +// Check if reportNew contains any of the specified emojis + if(!containsEmojis(reportNew) && (ignoreNew)){ + // console.log("No relevant emoji found, exiting script."); + process.exit(1); // Exit the script +} + + // ========== REPORT FINDINGS ========== // remove \n from end of report reportOld = reportOld.slice(0, -1); reportNew = reportNew.slice(0, -1); + + const directoryPath = path.join("./storage_delta", contractPath.dir); // Create directories recursively diff --git a/run.sh b/run.sh index 7330683..2249268 100755 --- a/run.sh +++ b/run.sh @@ -1,5 +1,34 @@ #!/bin/bash +# Variable to store whether --ignore was used in parameters +IGNORE_NEW=0 +POSITIONAL_ARGS=() + +# Parsing the command-line arguments +while [[ $# -gt 0 ]]; do + case "$1" in + --skip) + shift # Remove --ignore from processing + if [[ $1 == "only-new" ]]; then + IGNORE_NEW=1 + shift # Remove the value from processing + else + echo "Error: --skip requires a value (e.g., only-new)." + exit 1 + fi + ;; + *) + # Store positional arguments + POSITIONAL_ARGS+=("$1") + shift + ;; + esac +done + +# Restore positional arguments +set -- "${POSITIONAL_ARGS[@]}" + + # CLONE OLD VERSION # Check if the commit hash argument is provided @@ -113,6 +142,6 @@ for line in "${filesWithPath_old[@]}"; do cd "$current_dir" output_new=$(forge inspect $formated_name storage) - node ./lib/storage-delta/_reporter.js "$output_old" "$output_new" ${line} + node ./lib/storage-delta/_reporter.js "$output_old" "$output_new" ${line} $IGNORE_NEW fi done \ No newline at end of file