autogen.sh: make npm install *more* robust

There is a category of failure of 'npm install' that leaves
node_modules/ in a corrupt state and won't be fixed by just running 'npm
install' again.  Try harder.

Closes #12537
This commit is contained in:
Allison Karlitskaya 2019-08-10 10:23:15 +02:00 committed by Martin Pitt
parent c047d26df7
commit 44a8198766
1 changed files with 13 additions and 2 deletions

View File

@ -44,8 +44,19 @@ fi
# Development dependencies: See node_modules/README
npm prune
# npm install is flaky, so give it a few tries
npm install || { sleep 30; npm install; } || { sleep 30; npm install; }
retries='3'
while ! npm install; do
# npm install is flaky, and when it fails, it usually leaves
# node_modules in a corrupt state, so if that happens, start over
# again from scratch
retries=$((${retries}-1))
if test ${retries} -eq 0; then
echo 'failed to install nodejs modules'
exit 1
fi
find node_modules -mindepth 1 -not -path node_modules/README -delete
done
rm -rf autom4te.cache