|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +# Abort the mission if any command fails |
| 4 | +set -e |
| 5 | + |
| 6 | +SCRIPTS=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) |
| 7 | +ROOT=$(dirname $SCRIPTS) |
| 8 | +TEMP=$(mktemp -d /tmp/react-native-XXXXXXXX) |
| 9 | + |
| 10 | +# To make sure we actually installed the local version |
| 11 | +# of react-native, we will create a temp file inside SampleApp |
| 12 | +# and check that it exists after `react-native init` |
| 13 | +MARKER=$(mktemp $ROOT/Examples/SampleApp/XXXXXXXX) |
| 14 | + |
| 15 | +function cleanup { |
| 16 | + rm $MARKER |
| 17 | + [ $SINOPIA_PID ] && kill -9 $SINOPIA_PID |
| 18 | + [ -f ~/.npmrc.bak ] && mv ~/.npmrc.bak ~/.npmrc |
| 19 | +} |
| 20 | +trap cleanup EXIT |
| 21 | + |
| 22 | +cd $TEMP |
| 23 | + |
| 24 | +# sinopia is npm registry proxy, it is used to make npm |
| 25 | +# think react-native and react-native-cli are actually |
| 26 | +# published on npm |
| 27 | +which sinopia || npm install -g sinopia |
| 28 | + |
| 29 | +# but in order to make npm use sinopia we temporarily |
| 30 | +# replace its config file |
| 31 | +[ -f ~/.npmrc ] && cp ~/.npmrc ~/.npmrc.bak |
| 32 | +cp $SCRIPTS/e2e-npmrc ~/.npmrc |
| 33 | + |
| 34 | +sinopia --config $SCRIPTS/e2e-sinopia.config.yml & |
| 35 | +SINOPIA_PID=$! |
| 36 | + |
| 37 | +# Make sure to remove old version of react-native in |
| 38 | +# case it was cached |
| 39 | +npm unpublish react-native --force |
| 40 | +npm unpublish react-native-cli --force |
| 41 | +npm publish $ROOT |
| 42 | +npm publish $ROOT/react-native-cli |
| 43 | + |
| 44 | + |
| 45 | +npm install -g react-native-cli |
| 46 | +react-native init EndToEndTest |
| 47 | +cd EndToEndTest |
| 48 | + |
| 49 | +# Make sure we installed local version of react-native |
| 50 | +ls `basename $MARKER` > /dev/null |
| 51 | + |
| 52 | +xctool -scheme EndToEndTest -sdk iphonesimulator test |
0 commit comments