-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathinstall_react_native.sh
executable file
·78 lines (53 loc) · 1.69 KB
/
install_react_native.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/bin/bash
SCRIPT_NAME=$(basename $BASH_SOURCE)
SCRIPT_LOGFILE="./logs/"$(basename -s .sh $BASH_SOURCE)".log"
SCRIPT_ENVFILE="./logs/"$(basename -s .sh $BASH_SOURCE)".env"
mkdir -p ./logs && chmod 755 ./logs
echo "running "$SCRIPT_NAME
# tested: works on ubuntu 14.04.3 gnome
# see http://facebook.github.io/react-native/docs/getting-started.html#content
# todo: better check
# check android sdk
if hash adb 2>/dev/null; then
echo " checking adb => ok"
else
echo " checking adb => adb not installed, please install it and retry"
exit;
fi
# checking nodejs
if hash node 2>/dev/null; then
echo " checking node => ok"
else
echo " checking node => node not installed, please install it and retry"
exit;
fi
# checking npm
if hash npm 2>/dev/null; then
echo " checking npm => ok"
else
echo " checking npm => npm not installed, please install it and retry"
exit;
fi
if hash react-native 2>/dev/null; then
echo " react-native already installed"
else
echo " react-native not installed => installing react-native"
npm install -g react-native-cli &>> $SCRIPT_LOGFILE
echo ""
echo " WARNING: You need android 5 to make it work for android (because of adb reverse command)"
echo ""
echo " Here is how to run a hello world on your device:"
echo " cd ~/Desktop && react-native init AwesomeProject # this will take a while"
echo " cd AwesomeProject"
echo " react-native run-android"
echo ""
echo " in another shell, run:"
echo " react-native start"
echo ""
echo " In 3rd shell, run:"
echo " adb reverse tcp:8081 tcp:8081"
echo ""
echo ""
echo " See http://stackoverflow.com/questions/32572399/react-native-android-failed-to-load-js-bundle#answer-32574231"
echo ""
fi