forked from basecamp/pow
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·36 lines (31 loc) · 1012 Bytes
/
build.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
#!/bin/sh -e
# `./build.sh` generates dist/$VERSION.tar.gz
# `./build.sh --install` installs into ~/Library/Application Support/Pow/Current
VERSION=$(node -e 'console.log(JSON.parse(require("fs").readFileSync("package.json","utf8")).version); ""')
ROOT="/tmp/pow-build.$$"
DIST="$(pwd)/dist"
cake build
mkdir -p "$ROOT/$VERSION/node_modules"
cp -R package.json bin lib "$ROOT/$VERSION"
cp Cakefile "$ROOT/$VERSION"
cd "$ROOT/$VERSION"
BUNDLE_ONLY=1 npm install --production &>/dev/null
cp `which node` bin
if [ "$1" == "--install" ]; then
POW_ROOT="$HOME/Library/Application Support/Pow"
rm -fr "$POW_ROOT/Versions/9999.0.0"
mkdir -p "$POW_ROOT/Versions"
cp -R "$ROOT/$VERSION" "$POW_ROOT/Versions/9999.0.0"
rm -f "$POW_ROOT/Current"
cd "$POW_ROOT"
ln -s Versions/9999.0.0 Current
echo "$POW_ROOT/Versions/9999.0.0"
else
cd "$ROOT"
tar czf "$VERSION.tar.gz" "$VERSION"
mkdir -p "$DIST"
cd "$DIST"
mv "$ROOT/$VERSION.tar.gz" "$DIST"
echo "$DIST/$VERSION.tar.gz"
fi
rm -fr "$ROOT"