33# https://stackoverflow.com/a/4785518/881224
44which wget > /dev/null 2>&1 || { echo " Install wget and try again. Aborting." >&2 ; exit 1; }
55
6+ reinstall=0
7+ [ " $1 " == ' -f' ] && reinstall=1
8+ has_chrome=0
9+ [ -f ' bin/selenium/chromedriver' ] && has_chrome=1
10+ has_gecko=0
11+ [ -f ' bin/selenium/geckodriver' ] && has_gecko=1
12+ has_standalone=0
13+ [ -f ' bin/selenium/selenium-server-standalone.jar' ] && has_standalone=1
14+
615# remove sources
7- find bin/selenium/. ! -name ' .gitignore' -type f -exec rm -f {} +
16+ [ $reinstall == " 1 " ] && find bin/selenium/. ! -name ' .gitignore' -type f -exec rm -f {} +
817# remove symlinks (see bottom of script, "ln -s")
9- rm -f node_modules/.bin/{gecko,chromedriver,selenium}*
18+ [ $reinstall == " 1 " ] && rm -f node_modules/.bin/{gecko,chromedriver,selenium}*
1019
1120platform_gecko=' linux64'
1221platform_chrome=' linux64'
@@ -16,14 +25,22 @@ TARFILE_GECKO=v0.18.0/geckodriver-v0.18.0-${platform_gecko}.tar.gz
1625TARFILE_CHROME=2.33/chromedriver_${platform_chrome} .zip
1726TARFILE_STANDALONE=' 3.4/selenium-server-standalone-3.4.0.jar'
1827
19- echo Downloading ${TARFILE_GECKO}
20- wget -nc -q https://{GH_TOKEN}@github.com/mozilla/geckodriver/releases/download/${TARFILE_GECKO} -O bin/selenium/geckodriver-v0.18.0.tar.gz
21- echo Downloading ${TARFILE_CHROME}
22- wget -nc -q https://chromedriver.storage.googleapis.com/${TARFILE_CHROME} -O bin/selenium/chromedriver_2.31.zip
23- echo Downloading ${TARFILE_STANDALONE}
24- wget -nc -q https://selenium-release.storage.googleapis.com/${TARFILE_STANDALONE} -O bin/selenium/selenium-server-standalone.jar
25- tar -xzf bin/selenium/geckodriver-v0.18.0.tar.gz -C bin/selenium/
26- unzip -o bin/selenium/chromedriver_2.31.zip -d bin/selenium/
28+ if [ $reinstall == " 1" ] || [ $has_gecko == " 0" ]; then
29+ echo Downloading ${TARFILE_GECKO}
30+ wget -nc -q https://{GH_TOKEN}@github.com/mozilla/geckodriver/releases/download/${TARFILE_GECKO} -O bin/selenium/geckodriver-v0.18.0.tar.gz
31+ tar -xzf bin/selenium/geckodriver-v0.18.0.tar.gz -C bin/selenium/
32+ fi
33+
34+ if [ $reinstall == " 1" ] || [ $has_chrome == " 0" ]; then
35+ echo Downloading ${TARFILE_CHROME}
36+ wget -nc -q https://chromedriver.storage.googleapis.com/${TARFILE_CHROME} -O bin/selenium/chromedriver_2.31.zip
37+ unzip -o bin/selenium/chromedriver_2.31.zip -d bin/selenium/
38+ fi
39+
40+ if [ $reinstall == " 1" ] || [ $has_chrome == " 0" ]; then
41+ echo Downloading ${TARFILE_STANDALONE}
42+ wget -nc -q https://selenium-release.storage.googleapis.com/${TARFILE_STANDALONE} -O bin/selenium/selenium-server-standalone.jar
43+ fi
2744
2845# puts `bin/selenium/*` (chromedriver/geckodriver/selenium) on the PATH via `node_modules/.bin`
29- cd node_modules/.bin/ && ln -s ../../bin/selenium/* .
46+ cd node_modules/.bin/ && ln -sf ../../bin/selenium/* .
0 commit comments