Skip to content

Commit 55fa528

Browse files
committed
Refactor setup-and-run-periphery.sh
Add --disable-update-check and --relative-results flags DRY some code to avoid repetition of the commands to run scan
1 parent 5f1c6f0 commit 55fa528

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

Scripts/Periphery/setup-and-run-periphery.sh

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ PERIPHERY_PATH="${PERIPHERY_FOLDER_PATH}/periphery"
1212
version_gt() { test "$(printf '%s\n' "$@" | sort -V | head -n 1)" != "$1"; }
1313

1414
# Function to update and run Periphery
15-
update_and_run() {
16-
echo "Downloading the latest version..."
15+
update_periphery() {
16+
echo "Downloading version $PERIPHERY_VERSION..."
1717
# Download the zip file
1818
curl -L "https://github.com/peripheryapp/periphery/releases/download/${PERIPHERY_VERSION}/periphery-${PERIPHERY_VERSION}.zip" -o "periphery.zip"
1919

@@ -29,9 +29,7 @@ update_and_run() {
2929
# Make sure the executable is executable
3030
chmod +x "$PERIPHERY_PATH"
3131

32-
echo "Download and setup complete. Running periphery scan..."
33-
# Run periphery scan with additional arguments
34-
$PERIPHERY_PATH scan "$@"
32+
echo "Download and setup complete."
3533
}
3634

3735
# Check if the executable exists and is executable
@@ -43,12 +41,15 @@ if [ -x "$PERIPHERY_PATH" ]; then
4341
# Compare the current version with the desired version
4442
if version_gt "$PERIPHERY_VERSION" "$CURRENT_VERSION"; then
4543
echo "Current version ($CURRENT_VERSION) is older than $PERIPHERY_VERSION. Updating..."
46-
update_and_run "$@"
44+
update_periphery
4745
else
48-
echo "Current version ($CURRENT_VERSION) is up-to-date. Running periphery scan..."
49-
$PERIPHERY_PATH scan "$@"
46+
echo "Current version ($CURRENT_VERSION) is up-to-date."
5047
fi
5148
else
5249
echo "Executable not found. Downloading..."
53-
update_and_run "$@"
50+
update_periphery
5451
fi
52+
53+
echo "Running periphery scan..."
54+
# Run periphery scan with additional arguments
55+
"$PERIPHERY_PATH" scan --disable-update-check --relative-results "$@"

0 commit comments

Comments
 (0)