forked from sensiblecodeio/custard
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathactivate
95 lines (81 loc) · 2.24 KB
/
activate
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#!/bin/sh
# run me with . activate
OLD_PATH=$PATH
OLD_PS1=$PS1
OLD_NODE_PATH=$NODE_PATH
PATH=$(pwd)/node_modules/.bin:$(pwd)/bin:$PATH
# Fiddling with NODE_PATH appears not to be necessary. (node
# picks up modules from ./node_modules, but maybe that's only
# because i'm using nvm)
# Add ./code to NODE_PATH, adding a separating ':' if NODE_PATH
# is already set.
# See http://pubs.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html#tag_02_06_02
export NODE_PATH=$(pwd)/server/code${NODE_PATH+:}${NODE_PATH}
thisdir=$(basename "$(pwd)")
first2=$(printf '%.2s' "$thisdir")
PS1="[$first2]$PS1"
deactivate () {
PATH=$OLD_PATH
PS1=$OLD_PS1
NODE_PATH=$OLD_NODE_PATH
unset -f deactivate
unset -f mocha
}
mocha () {
# Clean DB out and load fixtures
coffee test/cleaner.coffee
# Consider pushing to external program.
eval last=\${$#}
if [ "$#" = "0" ]
then
env mocha ${@:1:$#-1} $(find test -name '*.coffee' | sort)
else
if [ -d "$last" ]
then
env mocha ${@:1:$#-1} $(find "$last" -name '*.coffee' | sort)
else
env mocha $@
fi
fi
}
fix_connect_file_cache () {
if ! [ -d node_modules/connect-assets ]
then
echo "connect-assets not found, please run npm install" 1>&2
return 4
fi
# node's module connect-file-cache has a bug, so we have to patch it.
# Unfortunately it's a dependency of a dependency, so we need to do
# this slightly elaborate "npm link" thing to change the installed
# module.
# See also our pull request:
# https://github.com/TrevorBurnham/connect-file-cache/pull/9
if [ -L node_modules/connect-assets/node_modules/connect-file-cache ]
then
return 0
fi
(
cd ..
git clone git://github.com/scraperwiki/connect-file-cache.git
cd connect-file-cache
npm link
)
(
cd node_modules/connect-assets
npm link connect-file-cache
)
}
turn_off_uglify_mangling() {
sed -i '/^ ast = pro.ast_mangle(ast);/s/^/\/\//' node_modules/connect-assets/node_modules/snockets/lib/snockets.js
}
s=../swops-secret/keys.sh
test -e "$s" && . "$s" && echo yummm, keys.sh
if [ "$NODE_ENV" = "production" ]
then
turn_off_uglify_mangling
fi
if [ "${NODE_ENV:-test}" = "test" ]
then
fix_connect_file_cache
fi
true