Skip to content

Commit 9463182

Browse files
committed
Only show log info when something has been logged
1 parent a7dc9b1 commit 9463182

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

bin/ruby-build

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,29 @@ build_failed() {
2828
echo "BUILD FAILED"
2929
echo
3030
echo "Inspect or clean up the working tree at ${TEMP_PATH}"
31-
echo "Results logged to ${LOG_PATH}"
32-
echo "Last 10 log lines:"
33-
tail -n 10 $LOG_PATH
31+
32+
if file_is_not_empty "$LOG_PATH"; then
33+
echo "Results logged to ${LOG_PATH}"
34+
echo
35+
echo "Last 10 log lines:"
36+
tail -n 10 "$LOG_PATH"
37+
fi
3438
} >&3
3539
exit 1
3640
}
3741

42+
file_is_not_empty() {
43+
local filename="$1"
44+
local line_count="$(wc -l "$filename" 2>/dev/null || true)"
45+
46+
if [ -n "$line_count" ]; then
47+
words=( $line_count )
48+
[ "${words[0]}" -gt 0 ]
49+
else
50+
return 1
51+
fi
52+
}
53+
3854
install_package() {
3955
install_package_using "tarball" 1 $*
4056
}

0 commit comments

Comments
 (0)