-
Notifications
You must be signed in to change notification settings - Fork 0
/
dev.env
68 lines (49 loc) · 1.92 KB
/
dev.env
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
#!/bin/bash
# base project configuration
# --------------------------------------------------------------------
# APP_NAME and APP_ROOT enviroment variables
# - all other project automation relies depends on this value being set here.
export APP_NAME=foxsays
export APP_ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# prereqs - warn people if stuff isn't installed
# --------------------------------------------------------------------
which go > /dev/null || echo 'error: `go` not found, is it installed?'
which node > /dev/null || echo 'error: `node` not found, is it installed?'
which supervise > /dev/null || echo 'error: `supervise` not found, is daemontools installed?'
# utility functions
# --------------------------------------------------------------------
function ensureDir {
test -d $1 || mkdir -p $1
}
function safePrefixPATH {
# conditionally update the PATH environment variable - don't
# update PATH if it already contains the path being passed in.
if [[ ! ":$PATH:" == *":$1:"* ]]; then
export PATH=$1:$PATH;
fi
}
# extended project environment configuration (rarely change)
# --------------------------------------------------------------------
export GOPATH=$APP_ROOT/server
export NODE_PATH=$APP_ROOT/client/node_modules
safePrefixPATH $APP_ROOT/client/script
safePrefixPATH $APP_ROOT/server/script
safePrefixPATH $GOPATH/bin
safePrefixPATH $NODE_PATH/.bin
# ensure core project structure and dependencies exist
# --------------------------------------------------------------------
ensureDir $APP_ROOT/client/dist
ensureDir $APP_ROOT/client/pkg
ensureDir $GOPATH/bin
ensureDir $GOPATH/pkg
ensureDir $GOPATH/src/$APP_NAME
# extended setup -- more time consuming, and skippable for sub-scripts
# --------------------------------------------------------------------
if [ "$1" != "fast" ]
then
pushd $APP_ROOT/client > /dev/null
npm install
bower install
popd > /dev/null
go get -t $APP_NAME/...
fi