Skip to content

Commit 45087a7

Browse files
committed
chore: remove incactive browserstack wrapper package
No longer uses the "inactive" browserstack wrapper package from npm, which was just responsible for creating the readyfile. We can create the readyfile ourself and get rid of the npm package.
1 parent cf1b4b9 commit 45087a7

File tree

3 files changed

+66
-62
lines changed

3 files changed

+66
-62
lines changed

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@
5151
"@types/node": "^6.0.34",
5252
"@types/run-sequence": "0.0.27",
5353
"@types/rx": "^2.5.33",
54-
"browserstacktunnel-wrapper": "^2.0.0",
5554
"conventional-changelog": "^1.1.0",
5655
"express": "^4.14.0",
5756
"firebase-tools": "^2.2.1",

scripts/browserstack/start_tunnel.js

Lines changed: 0 additions & 59 deletions
This file was deleted.

scripts/browserstack/start_tunnel.sh

Lines changed: 66 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,67 @@
1-
export BROWSER_STACK_ACCESS_KEY=`echo $BROWSER_STACK_ACCESS_KEY | rev`
1+
#!/bin/bash
22

3-
node ./scripts/browserstack/start_tunnel.js &
3+
set -e -o pipefail
4+
5+
TUNNEL_FILE="BrowserStackLocal-linux-x64.zip"
6+
TUNNEL_URL="https://www.browserstack.com/browserstack-local/$TUNNEL_FILE"
7+
TUNNEL_DIR="/tmp/browserstack-tunnel"
8+
TUNNEL_LOG="$LOGS_DIR/browserstack-tunnel.log"
9+
10+
BROWSER_STACK_ACCESS_KEY=`echo $BROWSER_STACK_ACCESS_KEY | rev`
11+
12+
# Cleanup and create the folder structure for the tunnel connector.
13+
rm -rf $TUNNEL_DIR $BROWSER_PROVIDER_READY_FILE
14+
mkdir -p $TUNNEL_DIR
15+
touch $TUNNEL_LOG
16+
17+
cd $TUNNEL_DIR
18+
19+
# Download the saucelabs connect binaries.
20+
curl $TUNNEL_URL -o $TUNNEL_FILE 2> /dev/null 1> /dev/null
21+
22+
# Extract the saucelabs connect binaries from the tarball.
23+
mkdir -p browserstack-tunnel
24+
unzip -q $TUNNEL_FILE -d browserstack-tunnel
25+
26+
# Cleanup the download directory.
27+
rm $TUNNEL_FILE
28+
29+
ARGS=""
30+
31+
# Set tunnel-id only on Travis, to make local testing easier.
32+
if [ ! -z "$TRAVIS_JOB_NUMBER" ]; then
33+
ARGS="$ARGS --local-identifier $TRAVIS_JOB_NUMBER"
34+
fi
35+
36+
echo "Starting Browserstack Local in the background, logging into:"
37+
echo " $TUNNEL_LOG"
38+
echo " ---"
39+
echo " $ARGS"
40+
41+
# Extension to the BrowserStackLocal binaries, because those can't create a readyfile.
42+
function create_ready_file {
43+
44+
# To be able to exit the tail properly we need to have a sub shell spawned, which is
45+
# used to track the state of tail.
46+
sleep 120 &
47+
48+
TIMER_PID=$!
49+
50+
# Disown the background process, because we don't want to show any messages when killing
51+
# the timer.
52+
disown
53+
54+
# When the tail recognizes the `Ctrl-C` log message the BrowserStack Tunnel is up.
55+
{
56+
tail -n0 -f $TUNNEL_LOG --pid $TIMER_PID | { sed '/Ctrl/q' && kill -9 $TIMER_PID; };
57+
} &> /dev/null
58+
59+
echo "BrowserStack Tunnel ready"
60+
61+
touch $BROWSER_PROVIDER_READY_FILE
62+
}
63+
64+
browserstack-tunnel/BrowserStackLocal -k $BROWSER_STACK_ACCESS_KEY $ARGS &>> $TUNNEL_LOG &
65+
66+
# Wait for the tunnel to be ready and create the readyfile with the Browserstack PID
67+
create_ready_file &

0 commit comments

Comments
 (0)