-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall-example.sh
More file actions
executable file
·61 lines (44 loc) · 1.3 KB
/
install-example.sh
File metadata and controls
executable file
·61 lines (44 loc) · 1.3 KB
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
#!/bin/bash
DIR="example"
BUILD_DIR="build"
REMOVE_EXAMPLE_DIR_PROMPT="Example directory exists already. Delete it? (y/N) "
BUILD_PROMPT="The build folder doesn't exists. However you'll need to build it to use the lib from the example project"
BUILD_PROMPT2="Would you like to build the library? (Y/n)"
Y_DEFAULT="y"
N_DEFAULT="n"
execute() {
"$@"
local status=$?
if [ $status -ne 0 ]; then
echo "Error with $1" >&2
exit $status
fi
return $status
}
if [ ! -d "$BUILD_DIR" ]; then
echo $BUILD_PROMPT
read -p "$BUILD_PROMPT2" -e answer
answer=${answer:-$Y_DEFAULT}
case $answer in
[Yy]* ) execute npm install; execute npm run build;;
[Nn]* );;
* ) echo "Invalid response."; exit 1;;
esac
fi
if [ -d "$DIR" ]; then
read -p "$REMOVE_EXAMPLE_DIR_PROMPT" -e answer
answer=${answer:-$N_DEFAULT}
case $answer in
[Yy]* ) echo "Removing existing directory"; rm -rf $DIR;;
[Nn]* ) exit 1;;
* ) echo "Invalid response."; exit 1;;
esac
fi
npm run example:create
npm link
cp -r example-templates/* example
cd example || (echo "Error when accessing the $DIR directory"; exit 1)
execute sed -i '' 's/module.exports = {/module.exports = {root:true,/g' .eslintrc.cjs
npm install
npm install @psyycker/react-translation -S
npm link @psyycker/react-translation