Skip to content

Commit f9e5709

Browse files
committed
fix(npm): Avoid selenium reinstall unless '-f' is used
From now on, run yarn run webdriver:update -f to force a reinstall of chromedriver, geckodriver, and standalone.
1 parent b5b9952 commit f9e5709

File tree

2 files changed

+30
-12
lines changed

2 files changed

+30
-12
lines changed

bin/start.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ browserSync.init({
5252
{
5353
match: [
5454
`${CONFIG.testDir}/**/*.ts`,
55-
`!${CONFIG.testDir}/built/**/*`
55+
`!${CONFIG.testDir}/node_modules/**`,
56+
`!${CONFIG.testDir}/built/**/*`,
5657
],
5758
fn: () => {
5859
const tsc = exec('yarn run build', { cwd: CONFIG.testDir });

test/scripts/webdriver-update

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,19 @@
33
# https://stackoverflow.com/a/4785518/881224
44
which 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

1120
platform_gecko='linux64'
1221
platform_chrome='linux64'
@@ -16,14 +25,22 @@ TARFILE_GECKO=v0.18.0/geckodriver-v0.18.0-${platform_gecko}.tar.gz
1625
TARFILE_CHROME=2.33/chromedriver_${platform_chrome}.zip
1726
TARFILE_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

Comments
 (0)