Created
January 31, 2023 15:47
-
-
Save johanbove/d495229272fb55feb0b3c81cfde92551 to your computer and use it in GitHub Desktop.
This script will attempt to add packages to npm cache after they returned with the ECONN error
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
echo "This script will attempt to add packages that return ECONN on the first try automatically." | |
logLevel="info" | |
echo "Setting config to loglevel: $logLevel" | |
npm config set loglevel=$logLevel | |
parse () { | |
echo "Starting npm ci..." | |
npm ci --legacy-peer-deps 2>&1 | | |
while read -r line; do | |
echo "Reading line: $line" | |
logLineWithErr=$(echo $line | grep -E -o '(http.+\.tgz)') | |
echo "logLineWithErr: ${#logLineWithErr}" | |
if [ ! -z "$logLineWithErr" -a "$logLineWithErr" != " " ]; then | |
echo "FOUND TGZ URL: $logLineWithErr" | |
url=$(echo $logLineWithErr | grep -E -o '(\/\/.*\.tgz)') | |
echo "url: ${#url}" | |
if [ ! -z "$url" -a "$url" != " " ]; then | |
echo "RETRY! Should do an npm cache add for: $url" | |
$(npm cache add https:$url) | |
# Start over | |
echo "STARTING OVER..." | |
parse | |
fi | |
fi | |
done | |
} | |
run () { | |
parse | |
} | |
run |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment