-
Notifications
You must be signed in to change notification settings - Fork 2
/
deps.sh
executable file
·65 lines (51 loc) · 1.13 KB
/
deps.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
#!/bin/bash
abspath() { cd $(dirname $1); echo $(pwd)/$(basename $1); }
usage="USAGE: $0 (update|update-go|update-js|compact-js) <heim-dir>"
update_js_deps() {
cp $HEIMDIR/client/package.json ./
npm install
rm package.json
}
compact_js_deps() {
cp $HEIMDIR/client/package.json ./
# a few hacks to reduce footprint...
# remove tests
find -name test -type d -print0 | xargs -0 rm -r
# merge devDependencies into dependencies so `npm dedupe` considers them.
perl -0777 -i.original -pe 's/\n },\n "devDependencies": {\n/,\n/igs' package.json
for d in node_modules/*; do pushd $d; npm dedupe; popd; done
npm dedupe
rm package.json package.json.original
}
print_js_versions() {
set +x
echo "node `node -v`; npm `npm -v`"
}
if [[ "$1" = "" || "$2" = "" ]]; then
echo $usage
exit 1
fi
SRCDIR=$(dirname `abspath $0`)
HEIMDIR=$(abspath $2)
cd $SRCDIR
set -x
case $1 in
update-js)
update_js_deps
print_js_versions
date
;;
compact-js)
compact_js_deps
print_js_versions
date
;;
update)
update_js_deps
print_js_versions
date
;;
*)
echo $usage
exit 1
esac