-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsetup.sh
executable file
·52 lines (46 loc) · 1.27 KB
/
setup.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
#!/bin/bash
# Get the directory where this script is and set ROOT_DIR to that path. This
# allows script to be run from different directories but always act on the
# directory it is within.
ROOT_DIR="$(cd "$(dirname $0)"; pwd)";
PROJECT_NAME="node-chrome-runner"
# A simple bash script to run commands to setup and install all dev dependencies
# (including non-npm ones)
function runAndAssertCmd ()
{
echo "Running: $1"
echo
# We use set -e to make sure this will fail if the command returns an error
# code.
set -e && eval $1
}
# Just run the command, ignore errors (e.g. cp fails if a file already exists
# with "set -e")
function runCmd ()
{
echo "Running: $1"
echo
eval $1
}
function clean ()
{
runCmd "rm -r $ROOT_DIR/node_modules $ROOT_DIR/build"
}
function installDevDependencies ()
{
runCmd "cd $ROOT_DIR"
runAndAssertCmd "npm install"
runAndAssertCmd "node_modules/.bin/tsd reinstall --config ./third_party/tsd.json"
}
if [ "$1" == 'install' ]; then
installDevDependencies
elif [ "$1" == 'clean' ]; then
clean
else
echo "Usage: setup.sh [install|tools]"
echo " install Installs needed development dependencies into build/"
echo " clean Removes all dependencies installed by this script."
echo
echo ""
exit 0
fi