Skip to content

Commit

Permalink
added the parsing logic in run.sh for optional parameter and added t…
Browse files Browse the repository at this point in the history
…he case in _reported.js to skip in case skip is only-new and there is only new vars in the final report
  • Loading branch information
turingtribe committed Dec 15, 2023
1 parent a2bb37b commit 58e367b
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 1 deletion.
21 changes: 21 additions & 0 deletions _reporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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);
Expand All @@ -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
Expand Down
31 changes: 30 additions & 1 deletion run.sh
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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

0 comments on commit 58e367b

Please sign in to comment.