mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
833661452d
Summary: Moves the `retry3` utility function into its own file so that it can be reused in other steps that are not related to Android. Changelog: [Internal] Reviewed By: rickhanlonii, cipolleschi Differential Revision: D39889996 fbshipit-source-id: bf79cc19ad6178af0a0d8117a81116e0c32f4333
25 lines
448 B
Bash
Executable File
25 lines
448 B
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
function retry3 {
|
|
local n=1
|
|
local max=3
|
|
local delay=1
|
|
while true; do
|
|
# shellcheck disable=SC2015
|
|
"$@" && break || {
|
|
if [[ $n -lt $max ]]; then
|
|
((n++))
|
|
echo "Command failed. Attempt $n/$max:"
|
|
sleep $delay;
|
|
else
|
|
echo "The command has failed after $n attempts." >&2
|
|
return 1
|
|
fi
|
|
}
|
|
done
|
|
}
|
|
|
|
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
|
|
retry3 "$@"
|
|
fi
|